Pass the next header value to ipv6_dissect_next() as an argument.
authorGuy Harris <guy@alum.mit.edu>
Sun, 24 Jul 2016 07:59:06 +0000 (00:59 -0700)
committerGuy Harris <guy@alum.mit.edu>
Sun, 24 Jul 2016 08:00:39 +0000 (08:00 +0000)
That way, we don't rely on the ws_ip pointer being non-null.

Based on changes from Ib73410fd8575ad6c836311bbda87a0580e5640ac.

Bug: 12645
Change-Id: I8c74ba57637b6a125593c4711d7c21b9693c2c85
Reviewed-on: https://code.wireshark.org/review/16616
Reviewed-by: Guy Harris <guy@alum.mit.edu>
epan/dissectors/packet-ipsec.c
epan/dissectors/packet-ipv6.c
epan/dissectors/packet-ipv6.h
epan/dissectors/packet-mip6.c
epan/dissectors/packet-shim6.c

index 54480a778c9f2eba11581efe76c4cf8a81d8387b..3cc7f84328fa4c2cffb3ddaba7b95b23a4952598 100644 (file)
@@ -1141,7 +1141,7 @@ dissect_ah(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
   iph->ip_len -= ah_hdr_len;
 
   if (pinfo->dst.type == AT_IPv6) {
-    ipv6_dissect_next(next_tvb, pinfo, tree, iph);
+    ipv6_dissect_next(ah_nxt, next_tvb, pinfo, tree, iph);
   } else {
     /* do lookup with the subdissector table */
     saved_match_uint  = pinfo->match_uint;
index 0dd8aa4d6abfa77d8decf5e2087b672769fe8742..261ea180861eb0c223c53bfd0ef7ce406419c8de 100644 (file)
@@ -1155,7 +1155,7 @@ dissect_routing6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data
     iph->ip_nxt = rt.ip6r_nxt;
     iph->ip_len -= len;
     next_tvb = tvb_new_subset_remaining(tvb, len);
-    ipv6_dissect_next(next_tvb, pinfo, tree, iph);
+    ipv6_dissect_next(rt.ip6r_nxt, next_tvb, pinfo, tree, iph);
     return tvb_captured_length(tvb);
 }
 
@@ -1226,7 +1226,7 @@ dissect_fraghdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
             iph->ip_nxt = nxt;
             next_tvb = tvb_new_subset_remaining(tvb, offset);
             iph->ip_len = tvb_reported_length_remaining(next_tvb, 0);
-            ipv6_dissect_next(next_tvb, pinfo, tree, iph);
+            ipv6_dissect_next(nxt, next_tvb, pinfo, tree, iph);
             return tvb_captured_length(tvb);
         }
     }
@@ -1234,7 +1234,7 @@ dissect_fraghdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
     iph->ip_nxt = nxt;
     iph->ip_len -= 8;
     next_tvb = tvb_new_subset_remaining(tvb, offset);
-    ipv6_dissect_next(next_tvb, pinfo, tree, iph);
+    ipv6_dissect_next(nxt, next_tvb, pinfo, tree, iph);
     return tvb_captured_length(tvb);
 }
 
@@ -1827,7 +1827,7 @@ dissect_opts(tvbuff_t *tvb, int offset, proto_tree *tree, packet_info *pinfo, ws
     iph->ip_nxt = nxt;
     iph->ip_len -= len;
     next_tvb = tvb_new_subset_remaining(tvb, len);
-    ipv6_dissect_next(next_tvb, pinfo, tree, iph);
+    ipv6_dissect_next(nxt, next_tvb, pinfo, tree, iph);
     return tvb_captured_length(tvb);
 }
 
@@ -2208,32 +2208,32 @@ dissect_ipv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
     save_fragmented = pinfo->fragmented;
 
     next_tvb = tvb_new_subset_remaining(tvb, offset);
-    ipv6_dissect_next(next_tvb, pinfo, tree, iph);
+    ipv6_dissect_next(ipv6->ip6_nxt, next_tvb, pinfo, tree, iph);
 
     pinfo->fragmented = save_fragmented;
     return tvb_captured_length(tvb);
 }
 
 void
-ipv6_dissect_next(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ws_ip *iph)
+ipv6_dissect_next(guint nxt, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ws_ip *iph)
 {
     dissector_handle_t nxt_handle;
     ipv6_pinfo_t *ipv6_pinfo;
 
-    if (iph->ip_nxt == IP_PROTO_NONE) {
+    if (nxt == IP_PROTO_NONE) {
         col_set_str(pinfo->cinfo, COL_INFO, "IPv6 no next header");
         call_data_dissector(tvb, pinfo, tree);
         return;
     }
 
-    nxt_handle = dissector_get_uint_handle(ipv6_next_header_dissector_table, iph->ip_nxt);
+    nxt_handle = dissector_get_uint_handle(ipv6_next_header_dissector_table, nxt);
     if (nxt_handle != NULL) {
         call_dissector_with_data(nxt_handle, tvb, pinfo, tree, iph);
         return;
     }
 
     /* Done with extension header chain */
-    p_add_proto_data(pinfo->pool, pinfo, proto_ipv6, (pinfo->curr_layer_num<<8) | IPV6_PROTO_VALUE, GUINT_TO_POINTER(iph->ip_nxt));
+    p_add_proto_data(pinfo->pool, pinfo, proto_ipv6, (pinfo->curr_layer_num<<8) | IPV6_PROTO_VALUE, GUINT_TO_POINTER(nxt));
     ipv6_pinfo = p_get_ipv6_pinfo(pinfo);
     if (ipv6_pinfo->ipv6_tree != NULL) {
         proto_item_set_len(proto_tree_get_parent(ipv6_pinfo->ipv6_tree), ipv6_pinfo->ipv6_item_len);
index 8a534fba90b5fc5aa1501cdb72d0f72dfa2d12fb..fdac35e8ab4dd5dc4be7f1c64e017c0dc50c8a5f 100644 (file)
@@ -114,7 +114,7 @@ ipv6_pinfo_t *p_get_ipv6_pinfo(packet_info *pinfo);
 
 gboolean capture_ipv6(const guchar *, int, int, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header);
 
-void ipv6_dissect_next(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ws_ip *iph);
+void ipv6_dissect_next(guint nxt, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ws_ip *iph);
 
 #ifdef __cplusplus
 }
index 607c0f06865bdc898f57807579deb2eb61534abf..b6adb249e861876d24ae28d6730b8662a6f70d18 100644 (file)
@@ -4231,7 +4231,7 @@ dissect_mip6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
         next_tvb = tvb_new_subset_remaining(tvb, len + 8);
         if (iph != NULL)
             iph->ip_len -= len + 8;
-        ipv6_dissect_next(next_tvb, pinfo, tree, iph);
+        ipv6_dissect_next(pproto, next_tvb, pinfo, tree, iph);
     }
 
     if ((type == MIP6_FBACK) && (pproto == IP_PROTO_AH)) {
@@ -4239,7 +4239,7 @@ dissect_mip6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
         next_tvb = tvb_new_subset_remaining(tvb, len + offset);
         if (iph != NULL)
             iph->ip_len -= len + offset;
-        ipv6_dissect_next(next_tvb, pinfo, tree, iph);
+        ipv6_dissect_next(pproto, next_tvb, pinfo, tree, iph);
     }
 
     return tvb_captured_length(tvb);
index bca8102bbaca5004b192dbe936c3bbdae78d4aa2..2eec53576b45c542180480f777b2f0af8e124368 100644 (file)
@@ -666,7 +666,7 @@ dissect_shim6(tvbuff_t *tvb, packet_info * pinfo, proto_tree *tree, void* data)
     iph->ip_nxt = shim.ip6s_nxt;
     iph->ip_len -= len;
     next_tvb = tvb_new_subset_remaining(tvb, len);
-    ipv6_dissect_next(next_tvb, pinfo, tree, iph);
+    ipv6_dissect_next(shim.ip6s_nxt, next_tvb, pinfo, tree, iph);
     return tvb_captured_length(tvb);
 }