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

snort-devel at ...616... snort-devel at ...616...
Sun Aug 19 00:04:03 EDT 2001


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

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




More information about the Snort-devel mailing list