]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
ipv6: convert ext header pointers to const
authorVictor Julien <victor@inliniac.net>
Wed, 17 Sep 2014 12:57:15 +0000 (14:57 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 23 Sep 2014 11:47:58 +0000 (13:47 +0200)
To prevent accidental writes into the orignal packet buffer, use
const pointers for the extension header pointers used by IPv6. This
will cause compiler warnings in case of writes.

src/decode-ipv6.h
src/defrag.c

index 23824269e170c2ff33331a710450610910641ef7..da58d9e2b384be8fe981e2e211321d1debc0afd9 100644 (file)
@@ -264,18 +264,18 @@ typedef struct IPV6GenOptHdr_
 
 typedef struct IPV6ExtHdrs_
 {
-    IPV6FragHdr    *ip6fh;
+    const IPV6FragHdr    *ip6fh;
     /* In fh_offset we store the offset of this extension into the packet past
      * the ipv6 header. We use it in defrag for creating a defragmented packet
      * without the frag header */
     uint16_t      fh_offset;
 
-    IPV6RouteHdr   *ip6rh;
-    IPV6AuthHdr    *ip6ah;
-    IPV6EspHdr     *ip6eh;
-    IPV6DstOptsHdr *ip6dh1;
-    IPV6DstOptsHdr *ip6dh2;
-    IPV6HopOptsHdr *ip6hh;
+    const IPV6RouteHdr   *ip6rh;
+    const IPV6AuthHdr    *ip6ah;
+    const IPV6EspHdr     *ip6eh;
+    const IPV6DstOptsHdr *ip6dh1;
+    const IPV6DstOptsHdr *ip6dh2;
+    const IPV6HopOptsHdr *ip6hh;
 
     /* Hop-By-Hop options */
     IPV6OptHAO ip6hh_opt_hao;
index c0088234df9e575381580d90607fd5b30f830c0a..7d38dec1c9e5d570a4d28d24ec7c1b8b7666d6d3 100644 (file)
@@ -1081,10 +1081,11 @@ IPV6BuildTestPacket(uint32_t id, uint16_t off, int mf, const char content,
     p->ip6h = (IPV6Hdr *)GET_PKT_DATA(p);
     IPV6_SET_RAW_VER(p->ip6h, 6);
     /* Fragmentation header. */
-    p->ip6eh.ip6fh = (IPV6FragHdr *)(GET_PKT_DATA(p) + sizeof(IPV6Hdr));
-    p->ip6eh.ip6fh->ip6fh_nxt = IPPROTO_ICMP;
-    p->ip6eh.ip6fh->ip6fh_ident = htonl(id);
-    p->ip6eh.ip6fh->ip6fh_offlg = htons((off << 3) | mf);
+    IPV6FragHdr *fh = (IPV6FragHdr *)(GET_PKT_DATA(p) + sizeof(IPV6Hdr));
+    fh->ip6fh_nxt = IPPROTO_ICMP;
+    fh->ip6fh_ident = htonl(id);
+    fh->ip6fh_offlg = htons((off << 3) | mf);
+    p->ip6eh.ip6fh = fh;
 
     pcontent = SCCalloc(1, content_len);
     if (unlikely(pcontent == NULL))