Project

General

Profile

Actions

Bug #858

closed

1.4.3: src/detect.h has anonymous structs in typedefs

Added by Mark Solaris almost 11 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
Affected Versions:
Effort:
Difficulty:
Label:

Description

Solaris Sun Studio 12.3 compiler adheres to the standard much better than gcc, it doesn't like anonymous structs.

"detect-app-layer-event.c", line 152: improper member use: alproto
"detect-app-layer-event.c", line 153: improper member use: alproto
"detect-app-layer-event.c", line 159: improper member use: alproto
"detect-app-layer-event.c", line 163: improper member use: flags
"detect-byte-extract.c", line 574: improper member use: alproto
"detect-byte-extract.c", line 592: improper member use: flags
"detect-byte-extract.c", line 596: improper member use: flags
"detect-byte-extract.c", line 600: improper member use: alproto
"detect-byte-extract.c", line 671: improper member use: alproto
"detect-bytejump.c", line 548: improper member use: alproto
"detect-bytejump.c", line 578: improper member use: flags
"detect-bytejump.c", line 582: improper member use: flags
"detect-bytejump.c", line 586: improper member use: alproto
"detect-bytejump.c", line 642: improper member use: alproto
"detect-bytetest.c", line 469: improper member use: alproto
"detect-bytetest.c", line 499: improper member use: flags
"detect-bytetest.c", line 503: improper member use: flags
"detect-bytetest.c", line 507: improper member use: alproto
"detect-bytetest.c", line 578: improper member use: alproto
"detect.c", line 501: improper member use: flags
"detect.c", line 502: improper member use: alproto
"detect.c", line 502: improper member use: alproto
"detect.c", line 503: improper member use: alproto
"detect.c", line 515: improper member use: flags
"detect.c", line 516: improper member use: dsize_low
"detect.c", line 516: improper member use: dsize_high
[...]

The offending typedefs:

src/detect.h:
   325  typedef struct SignatureHeader_ {
   326      union {
   327          struct {
   328              uint32_t flags;
   329              uint16_t alproto;
   330              uint16_t dsize_low;
   331          };
   332          uint64_t hdr_copy1;
   333      };
   334      union {
   335          struct {
   336              uint16_t dsize_high;
   337              uint16_t mpm_pattern_id_div_8;
   338          };
   339          uint32_t hdr_copy2;
   340      };
   341      union {
   342          struct {
   343              uint8_t mpm_pattern_id_mod_8;
   344              SignatureMask mask;
   345              SigIntId num; /**< signature number, internal id */
   346          };
   347          uint32_t hdr_copy3;
   348      };
   349      /** pointer to the full signature */
   350      struct Signature_ *full_sig;
   351  } SignatureHeader;

   363  typedef struct Signature_ {
   364      union {
   365          struct {
   366              uint32_t flags;
   367              uint16_t alproto;
   368              uint16_t dsize_low;
   369          };
   370          uint64_t hdr_copy1;
   371      };
   372      union {
   373          struct {
   374              uint16_t dsize_high;
   375              uint16_t mpm_pattern_id_div_8;
   376          };
   377          uint32_t hdr_copy2;
   378      };
   379      union {
   380          struct {
   381              uint8_t mpm_pattern_id_mod_8;
   382              SignatureMask mask;
   383              SigIntId num; /**< signature number, internal id */
   384          };
   385          uint32_t hdr_copy3;
   386      };

I've given the structs names (first, second, third) and gone through all 75 of the src/detect*.[c|h] files where they are referenced and fixed the code. See attached diff. Feel free to edit the struct names to suit their purpose :)

All the detect* files now compile with just warnings, not errors.


Files

detect.diffs (134 KB) detect.diffs Mark Solaris, 07/07/2013 08:16 PM
detect.diffs (137 KB) detect.diffs Mark Solaris, 07/07/2013 08:29 PM
detect.diffs (138 KB) detect.diffs Mark Solaris, 07/09/2013 04:43 AM
Actions #1

Updated by Mark Solaris almost 11 years ago

Updated the diff

Actions #3

Updated by Mark Solaris almost 11 years ago

Added a fix for src/util-threshold-config.c to the diff, it's the same struct problem so bundling into the same diff.

Actions #4

Updated by Victor Julien over 10 years ago

  • Target version set to TBD
Actions #5

Updated by Andreas Herz over 8 years ago

  • Status changed from New to Closed
Actions #6

Updated by Victor Julien over 6 years ago

  • Target version deleted (TBD)
Actions

Also available in: Atom PDF