]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Add Packed attribute on Header structures
authorKen Steele <ken@tilera.com>
Fri, 20 Dec 2013 16:52:12 +0000 (11:52 -0500)
committerVictor Julien <victor@inliniac.net>
Tue, 12 Aug 2014 10:29:18 +0000 (12:29 +0200)
Structures that are used to cast packet data into fields need to be packed
so that the compiler doesn't add any padding to these fields. This also helps
Tile-Gx to avoid unaligned loads because the compiler will insert code to
handle the possible unaligned load.

src/app-layer-dns-common.h
src/decode-tcp.h
src/decode-udp.h

index 9ae04c165d66876036aa9099ecf7ff2ea1e17d40..ab2d8ef11835c231af4ce75c83299e2291af12e0 100644 (file)
@@ -78,12 +78,12 @@ typedef struct DNSHeader_ {
     uint16_t answer_rr;
     uint16_t authority_rr;
     uint16_t additional_rr;
-} DNSHeader;
+} __attribute__((__packed__)) DNSHeader;
 
 typedef struct DNSQueryTrailer_ {
     uint16_t type;
     uint16_t class;
-} DNSQueryTrailer;
+} __attribute__((__packed__)) DNSQueryTrailer;
 
 /** \brief DNS answer header
  *  packed as we don't want alignment to mess up sizeof() */
index 067d4a4862e936a4e21a693aa143e060d7d3b80c..152d5103f42f2d66b6b8ac1702c5ad45676d35cd 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
@@ -136,7 +136,7 @@ typedef struct TCPHdr_
     uint16_t th_win;    /**< pkt window */
     uint16_t th_sum;    /**< checksum */
     uint16_t th_urp;    /**< urgent pointer */
-} TCPHdr;
+} __attribute__((__packed__)) TCPHdr;
 
 typedef struct TCPVars_
 {
index 2c3a7845d727336c7cc93edbd2d92b3fe808ad19..5636c32b0f42197db3e0831b3e00f3ca094c1614 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
@@ -42,7 +42,7 @@ typedef struct UDPHdr_
        uint16_t uh_dport;  /* destination port */
        uint16_t uh_len;    /* length */
        uint16_t uh_sum;    /* checksum */
-} UDPHdr;
+} __attribute__((__packed__)) UDPHdr;
 
 typedef struct UDPVars_
 {