]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
More structures that need to be marked Packed.
authorKen Steele <ken@tilera.com>
Fri, 20 Dec 2013 18:50:43 +0000 (13:50 -0500)
committerVictor Julien <victor@inliniac.net>
Tue, 12 Aug 2014 10:29:18 +0000 (12:29 +0200)
These structures are cast from raw packet data, so they should be packed.
The case is:

typedef struct Foo_ {
} Foo;

Foo *f = (Foo *)pkt;

src/alert-unified2-alert.c
src/decode-ethernet.h
src/decode-gre.h
src/decode-icmpv4.h
src/decode-ipv4.h
src/decode-ipv6.h
src/decode-ppp.h
src/decode-pppoe.h
src/decode-sctp.h
src/decode-sll.h
src/decode-vlan.h

index 6ff984fb567a34b9b3e7a9cdf8ef4d3e1ca1775d..bdf7c5e7b82fdb8552a7a3ecc72356f92015d950 100644 (file)
@@ -92,7 +92,7 @@ static uint32_t sensor_id = 0;
 typedef struct Unified2ExtraDataHdr_ {
     uint32_t event_type;
     uint32_t event_length;
-} Unified2ExtraDataHdr;
+} __attribute__((__packed__)) Unified2ExtraDataHdr;
 
 /**
  * Unified2 Extra Data (currently used only for XFF)
@@ -477,7 +477,7 @@ int Unified2Logger(ThreadVars *t, void *data, const Packet *p)
 typedef struct _FakeIPv4Hdr {
     IPV4Hdr ip4h;
     TCPHdr tcph;
-} FakeIPv4Hdr;
+} __attribute__((__packed__)) FakeIPv4Hdr;
 
 static int Unified2ForgeFakeIPv4Header(FakeIPv4Hdr *fakehdr, const Packet *p, int pkt_len, char invert)
 {
@@ -507,7 +507,7 @@ static int Unified2ForgeFakeIPv4Header(FakeIPv4Hdr *fakehdr, const Packet *p, in
 typedef struct _FakeIPv6Hdr {
     IPV6Hdr ip6h;
     TCPHdr tcph;
-} FakeIPv6Hdr;
+} __attribute__((__packed__)) FakeIPv6Hdr;
 
 /**
  *  \param payload_len length of the payload
index 829601f9ceacc29fd03cc3f1788619da0735b899..2a6f86e936a4ea1298fd31320d324d1fc26aca85 100644 (file)
@@ -45,7 +45,7 @@ typedef struct EthernetHdr_ {
     uint8_t eth_dst[6];
     uint8_t eth_src[6];
     uint16_t eth_type;
-} EthernetHdr;
+} __attribute__((__packed__)) EthernetHdr;
 
 #endif /* __DECODE_ETHERNET_H__ */
 
index 4dd0fa888afed719e9c29c3a751e1cb9304bfdfb..e5a4f4c17c1e0ad2816514da0e075044bf9af7bf 100644 (file)
@@ -37,7 +37,7 @@ typedef struct GREHdr_
     uint8_t version; /**< GRE version */
     uint16_t ether_type; /**< ether type of the encapsulated traffic */
 
-} GREHdr;
+} __attribute__((__packed__)) GREHdr;
 
 typedef struct GRESreHdr_
 {
@@ -45,7 +45,7 @@ typedef struct GRESreHdr_
     uint8_t sre_offset;
     uint8_t sre_length;
     uint8_t *routing;
-} GRESreHdr;
+} __attribute__((__packed__)) GRESreHdr;
 
 #define GRE_VERSION_0           0x0000
 #define GRE_VERSION_1           0x0001
index 9f37c383efcb0ec3e140b071f992812009bc181e..f8cb97f4f0ab4c313ad29ea5bb2e49a0f1c68bdb 100644 (file)
@@ -162,7 +162,7 @@ typedef struct ICMPV4Hdr_
     uint8_t  type;
     uint8_t  code;
     uint16_t checksum;
-} ICMPV4Hdr;
+} __attribute__((__packed__)) ICMPV4Hdr;
 
 /* ICMPv4 header structure */
 typedef struct ICMPV4ExtHdr_
index 3e0849fe6ffe699400d89675cc5d5033e8dd7ca2..be212bf2fadbe8f6fae5c234a98122bf07504c32 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2013 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -84,7 +84,7 @@ typedef struct IPV4Hdr_
         } ip4_un1;
         uint16_t ip_addrs[4];
     } ip4_hdrun1;
-} IPV4Hdr;
+} __attribute__((__packed__)) IPV4Hdr;
 
 
 #define s_ip_src                          ip4_hdrun1.ip4_un1.ip_src
index 9833e831a0d8f14f44cee127686019109e2c45e8..24dffb8fada542305ddea7ed7670f06a6a3180d8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2013 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -47,7 +47,7 @@ typedef struct IPV6Hdr_
         } ip6_un2;
         uint16_t ip6_addrs[16];
     } ip6_hdrun2;
-} IPV6Hdr;
+} __attribute__((__packed__)) IPV6Hdr;
 
 #define s_ip6_src                       ip6_hdrun2.ip6_un2.ip6_src
 #define s_ip6_dst                       ip6_hdrun2.ip6_un2.ip6_dst
@@ -126,7 +126,7 @@ typedef struct IPV6FragHdr_
     uint8_t  ip6fh_reserved;        /* reserved field */
     uint16_t ip6fh_offlg;           /* offset, reserved, and flag */
     uint32_t ip6fh_ident;           /* identification */
-} IPV6FragHdr;
+} __attribute__((__packed__)) IPV6FragHdr;
 
 #define IPV6_EXTHDR_GET_RAW_FH_NH(p)        ((p)->ip6eh.ip6fh->ip6fh_nxt)
 #define IPV6_EXTHDR_GET_RAW_FH_HDRLEN(p)    sizeof(IPV6FragHdr)
@@ -149,13 +149,13 @@ typedef struct IPV6AuthHdr_
     uint16_t ip6ah_reserved;        /* reserved for future use */
     uint32_t ip6ah_spi;             /* SECURITY PARAMETERS INDEX (SPI) */
     uint32_t ip6ah_seq;             /* sequence number */
-} IPV6AuthHdr;
+} __attribute__((__packed__)) IPV6AuthHdr;
 
 typedef struct IPV6EspHdr_
 {
     uint32_t ip6esph_spi;           /* SECURITY PARAMETERS INDEX (SPI) */
     uint32_t ip6esph_seq;           /* sequence number */
-} IPV6EspHdr;
+} __attribute__((__packed__)) IPV6EspHdr;
 
 typedef struct IPV6RouteHdr_
 {
@@ -168,7 +168,7 @@ typedef struct IPV6RouteHdr_
     uint8_t ip6rh0_num_addrs;        /* number of actual addresses in the
                                         array/packet. The array is guarranteed
                                         to be filled up to this number. */
-} IPV6RouteHdr;
+} __attribute__((__packed__)) IPV6RouteHdr;
 
 #define IPV6_EXTHDR_GET_RAW_RH_NH(p)        ((p)->ip6eh.ip6rh->ip6rh_nxt)
 #define IPV6_EXTHDR_GET_RAW_RH_HDRLEN(p)    ((p)->ip6eh.ip6rh->ip6rh_len)
@@ -219,7 +219,7 @@ typedef struct IPV6HopOptsHdr_
     uint8_t ip6hh_nxt;              /* next header */
     uint8_t ip6hh_len;              /* header length in units of 8 bytes, not
                                        including first 8 bytes. */
-} IPV6HopOptsHdr;
+} __attribute__((__packed__)) IPV6HopOptsHdr;
 
 #define IPV6_EXTHDR_GET_RAW_HH_NH(p)        ((p)->ip6eh.ip6hh->ip6hh_nxt)
 #define IPV6_EXTHDR_GET_RAW_HH_HDRLEN(p)    ((p)->ip6eh.ip6hh->ip6hh_len)
@@ -234,7 +234,7 @@ typedef struct IPV6DstOptsHdr_
     uint8_t ip6dh_nxt;              /* next header */
     uint8_t ip6dh_len;              /* header length in units of 8 bytes, not
                                        including first 8 bytes. */
-} IPV6DstOptsHdr;
+} __attribute__((__packed__)) IPV6DstOptsHdr;
 
 #define IPV6_EXTHDR_GET_RAW_DH1_NH(p)        ((p)->ip6eh.ip6dh1->ip6dh_nxt)
 #define IPV6_EXTHDR_GET_RAW_DH1_HDRLEN(p)    ((p)->ip6eh.ip6dh1->ip6dh_len)
index bf39f4a423412cd34bb8d5a3175de82f688a241d..00e61de9f9b4f3cface217ee782721e617cba7af 100644 (file)
@@ -65,7 +65,7 @@ typedef struct PPPHdr_ {
     uint8_t address;
     uint8_t control;
     uint16_t protocol;
-} PPPHdr;
+} __attribute__((__packed__)) PPPHdr;
 
 /** PPP Packet header length */
 #define PPP_HEADER_LEN 4
index 1455ea57f419d76b955e8ac25c2feced7e105b94..6aecf74151995cad5c3391db09ddc09434c72626 100644 (file)
@@ -47,7 +47,7 @@ typedef struct PPPOEDiscoveryTag_
 {
     uint16_t pppoe_tag_type;
     uint16_t pppoe_tag_length;
-} PPPOEDiscoveryTag;
+} __attribute__((__packed__)) PPPOEDiscoveryTag;
 
 typedef struct PPPOEDiscoveryHdr_
 {
@@ -55,7 +55,7 @@ typedef struct PPPOEDiscoveryHdr_
     uint8_t pppoe_code;
     uint16_t discovery_id;
     uint16_t pppoe_length;
-} PPPOEDiscoveryHdr;
+} __attribute__((__packed__)) PPPOEDiscoveryHdr;
 
 /* see RFC 2516 - discovery codes */
 #define PPPOE_CODE_PADI 0x09
index 878a583c2886289bfdc5440a60745af7aa0a27d0..184a172e6095954d46dda2ca253451029c56ce57 100644 (file)
@@ -40,7 +40,7 @@ typedef struct SCTPHdr_
     uint16_t sh_dport;     /* destination port */
     uint32_t sh_vtag;      /* verification tag, defined per flow */
     uint32_t sh_sum;       /* checksum, computed via crc32 */
-} SCTPHdr;
+} __attribute__((__packed__)) SCTPHdr;
 
 #define CLEAR_SCTP_PACKET(p) { \
     (p)->sctph = NULL; \
index ad8c7e62773f4f36fe6406aedf03dfaaa26ebcfa..babdd7ac21091cd7090117875d87fb88fe9b0856 100644 (file)
@@ -32,7 +32,7 @@ typedef struct SllHdr_ {
     uint16_t sll_halen;        /* link-layer address length */
     uint8_t sll_addr[8];       /* link-layer address */
     uint16_t sll_protocol;     /* protocol */
-} SllHdr;
+} __attribute__((__packed__)) SllHdr;
 
 #endif /* __DECODE_SLL_H__ */
 
index c82e33be12f8de9d0112454521874ba42ef9af38..baa364726f0c16abb99c28c22e1a5c7100dfa01a 100644 (file)
@@ -44,7 +44,7 @@ uint16_t DecodeVLANGetId(const struct Packet_ *, uint8_t layer);
 typedef struct VLANHdr_ {
     uint16_t vlan_cfi;
     uint16_t protocol;  /**< protocol field */
-} VLANHdr;
+} __attribute__((__packed__)) VLANHdr;
 
 /** VLAN header length */
 #define VLAN_HEADER_LEN 4