[Snort-devel] Invalid C code in log.c?

snort-devel at ...616... snort-devel at ...616...
Sun Aug 19 01:01:06 EDT 2001


On Sat, Aug 18, 2001 at 09:58:15PM -0700, Erek Adams wrote:
> On Sat, 18 Aug 2001 snort-devel at ...616... wrote:
> 
> > In snort 1.8.1, log.c has:
> >
> >             case TCPOPT_MAXSEG:
> >                 memset (tmp, 0, 5);
> >                 fwrite("MSS: ", 5, 1, fp);
> >                 strncpy((char*)tmp, (char*) (p->tcp_options[i].data), 2);
> >                 fprintf(fp, "%u ", EXTRACT_16BITS(tmp));
> >                 break;
> >
> > and decode.h has (WORDS_MUSTALIGN defined because this is Solaris
> > 2.6/SPARC):
> >   #define EXTRACT_32BITS(p)  ({ u_int32_t __tmp; memmove(&__tmp, (p),
> > sizeof(u_int32_t)); (u_int32_t) ntohl(__tmp);})
> >
> > This doesn't build with Solaris C. Is this even valid? gcc -ansi
> > -pedantic had this to say:
> >
> > log.c: In function `PrintTcpOptions':
> > log.c:2159: warning: ANSI C forbids braced-groups within expressions
> 
> Erf....  It builds and runs just fine on 2.7 mu4.  gcc 2.95.

Run it with gcc -ansi -pedantic and it'll fail. I have a workaround
along with some other patches I'll post in a bit.

-- 
albert chin (china at ...329...)




More information about the Snort-devel mailing list