From Andrej Mikus:
authorjake <jake@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 5 Feb 2007 21:42:41 +0000 (21:42 +0000)
committerjake <jake@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 5 Feb 2007 21:42:41 +0000 (21:42 +0000)
Wireshark complains about bogus udp length when processing last fragment of UDP data.
It compares length field from UDP header with payload size of last fragment.
Attached is my attempt to fix this by referring to tvp->length instead of pinfo->iplen - pinfo->iphdrlen.

Also set some items attribute to generated.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@20722 f5534014-38df-0310-8fa8-9805f1628bb7

epan/dissectors/packet-udp.c

index 24376b78c061f6a145de30dadef5c9a8540cfc6c..bbf4fc3453cb517ade83bee6feb47b2a6fdfb9e6 100644 (file)
@@ -234,11 +234,10 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
         col_append_fstr(pinfo->cinfo, COL_INFO, " [BAD UDP LENGTH %u < 8]", udph->uh_ulen);
       return;
     }
-    if ((udph->uh_ulen > pinfo->iplen - pinfo->iphdrlen) && ! pinfo->fragmented) {
+    if ((udph->uh_ulen > tvb->length) && ! pinfo->fragmented) {
       /* Bogus length - it goes past the end of the IP payload */
       item = proto_tree_add_uint_format(udp_tree, hf_udp_length, tvb, offset + 4, 2,
-          udph->uh_ulen, "Length: %u (bogus, should be %u)", udph->uh_ulen,
-          pinfo->iplen - pinfo->iphdrlen);
+          udph->uh_ulen, "Length: %u (bogus, payload length %u)", udph->uh_ulen, tvb->length);
       expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, "Bad length value %u > IP payload length", udph->uh_ulen);
       if (check_col(pinfo->cinfo, COL_INFO))
         col_append_fstr(pinfo->cinfo, COL_INFO, " [BAD UDP LENGTH %u > IP PAYLOAD LENGTH]", udph->uh_ulen);
@@ -372,20 +371,24 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
       item = proto_tree_add_uint_format(udp_tree, hf_udp_checksum, tvb,
         offset + 6, 2, udph->uh_sum, "Checksum: 0x%04x [validation disabled]", udph->uh_sum);
       checksum_tree = proto_item_add_subtree(item, ett_udp_checksum);
-      proto_tree_add_boolean(checksum_tree, hf_udp_checksum_good, tvb,
+      item = proto_tree_add_boolean(checksum_tree, hf_udp_checksum_good, tvb,
                              offset + 6, 2, FALSE);
-      proto_tree_add_boolean(checksum_tree, hf_udp_checksum_bad, tvb,
+      PROTO_ITEM_SET_GENERATED(item);
+      item = proto_tree_add_boolean(checksum_tree, hf_udp_checksum_bad, tvb,
                              offset + 6, 2, FALSE);
+      PROTO_ITEM_SET_GENERATED(item);
     }
   } else {     
     item = proto_tree_add_uint_format(udp_tree, hf_udp_checksum, tvb,
       offset + 6, 2, udph->uh_sum, "Checksum: 0x%04x", udph->uh_sum);
 
-      checksum_tree = proto_item_add_subtree(item, ett_udp_checksum);
-      proto_tree_add_boolean(checksum_tree, hf_udp_checksum_good, tvb,
+    checksum_tree = proto_item_add_subtree(item, ett_udp_checksum);
+    item = proto_tree_add_boolean(checksum_tree, hf_udp_checksum_good, tvb,
                              offset + 6, 2, FALSE);
-      proto_tree_add_boolean(checksum_tree, hf_udp_checksum_bad, tvb,
+    PROTO_ITEM_SET_GENERATED(item);
+    item = proto_tree_add_boolean(checksum_tree, hf_udp_checksum_bad, tvb,
                              offset + 6, 2, FALSE);
+    PROTO_ITEM_SET_GENERATED(item);
   }
 
   /* Skip over header */