diff options
author | Jaap Keuter <jaap.keuter@xs4all.nl> | 2006-01-12 22:16:20 +0000 |
---|---|---|
committer | Jaap Keuter <jaap.keuter@xs4all.nl> | 2006-01-12 22:16:20 +0000 |
commit | 6e80585275fa2719c42b528ae7b35bd758efb74f (patch) | |
tree | 14d07eb88419e16405f6bbe637c293cc8112abd2 /epan/dissectors/packet-udp.c | |
parent | 62a3709da359b1a26a8dbe221f8666c60a1311b7 (diff) |
Add warning when UDP length field is too large.
Patch by Graeme Hewson
svn path=/trunk/; revision=17023
Diffstat (limited to 'epan/dissectors/packet-udp.c')
-rw-r--r-- | epan/dissectors/packet-udp.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/epan/dissectors/packet-udp.c b/epan/dissectors/packet-udp.c index 53039ba17c..2fac3d829a 100644 --- a/epan/dissectors/packet-udp.c +++ b/epan/dissectors/packet-udp.c @@ -217,6 +217,7 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto) udph->uh_ulen = udph->uh_sum_cov = tvb_get_ntohs(tvb, offset+4); if (udph->uh_ulen < 8) { /* Bogus length - it includes the header, so it must be >= 8. */ + /* XXX - should handle IPv6 UDP jumbograms (RFC 2675), where the length is zero */ if (tree) { proto_tree_add_uint_format(udp_tree, hf_udp_length, tvb, offset + 4, 2, udph->uh_ulen, "Length: %u (bogus, must be >= 8)", udph->uh_ulen); @@ -224,8 +225,15 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto) return; } if (tree) { - proto_tree_add_uint(udp_tree, hf_udp_length, tvb, offset + 4, 2, udph->uh_ulen); - proto_tree_add_uint_hidden(udp_tree, hf_udplite_checksum_coverage, tvb, offset + 4, 0, udph->uh_sum_cov); + if ((udph->uh_ulen > pinfo->iplen - pinfo->iphdrlen) && ! pinfo->fragmented) { + 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); + } else { + proto_tree_add_uint(udp_tree, hf_udp_length, tvb, offset + 4, 2, udph->uh_ulen); + proto_tree_add_uint_hidden(udp_tree, hf_udplite_checksum_coverage, tvb, offset + 4, + 0, udph->uh_sum_cov); + } } } else { udph->uh_ulen = pinfo->iplen - pinfo->iphdrlen; |