From 9fd96f531a7babe1c54bc67a5d51825369e230ab Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Wed, 17 Sep 2014 14:57:15 +0200 Subject: [PATCH] ipv6: convert ext header pointers to const 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 | 14 +++++++------- src/defrag.c | 9 +++++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/decode-ipv6.h b/src/decode-ipv6.h index 23824269e1..da58d9e2b3 100644 --- a/src/decode-ipv6.h +++ b/src/decode-ipv6.h @@ -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; diff --git a/src/defrag.c b/src/defrag.c index c0088234df..7d38dec1c9 100644 --- a/src/defrag.c +++ b/src/defrag.c @@ -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))