Ethereal-dev: [Ethereal-dev] Patch: Correction for DNS A6 RR decoding.
Please find attached a proposed patch to fix an error in DNS A6 resource record decoding.
/Per
Index: packet-dns.c
===================================================================
RCS file: /cvsroot/ethereal/packet-dns.c,v
retrieving revision 1.55
diff -u -r1.55 packet-dns.c
--- packet-dns.c 2000/10/11 04:12:05 1.55
+++ packet-dns.c 2000/10/17 11:34:42
@@ -1477,7 +1477,7 @@
}
pre_len = pd[cur_offset++];
suf_len = 128 - pre_len;
- suf_octet_count = (suf_len - 1) / 8 + 1;
+ suf_octet_count = suf_len ? (suf_len - 1) / 8 + 1 : 0;
if (!BYTES_ARE_IN_FRAME(cur_offset, suf_octet_count)) {
/* We ran past the end of the captured data in the packet. */
return 0;
@@ -1490,11 +1490,15 @@
suffix[suf_offset] = pd[cur_offset++];
}
- pname_len = get_dns_name(pd, cur_offset, dns_data_offset,
- pname, sizeof(pname));
- if (pname_len < 0) {
- /* We ran past the end of the captured data in the packet. */
- return 0;
+ if (pre_len > 0) {
+ pname_len = get_dns_name(pd, cur_offset, dns_data_offset,
+ pname, sizeof(pname));
+ if (pname_len < 0) {
+ /* We ran past the end of the captured data in the packet. */
+ return 0;
+ }
+ } else {
+ strcpy(pname, "");
}
if (fd != NULL) {
@@ -1507,12 +1511,16 @@
proto_tree_add_text(rr_tree, NullTVB, a6_offset, 1,
"Prefix len: %u", pre_len);
a6_offset++;
- proto_tree_add_text(rr_tree, NullTVB, a6_offset, suf_octet_count,
- "Address suffix: %s",
- ip6_to_str((struct e_in6_addr *)&suffix));
- a6_offset += suf_octet_count;
- proto_tree_add_text(rr_tree, NullTVB, a6_offset, pname_len,
- "Prefix name: %s", pname);
+ if (suf_len) {
+ proto_tree_add_text(rr_tree, NullTVB, a6_offset, suf_octet_count,
+ "Address suffix: %s",
+ ip6_to_str((struct e_in6_addr *)&suffix));
+ a6_offset += suf_octet_count;
+ }
+ if (pre_len > 0) {
+ proto_tree_add_text(rr_tree, NullTVB, a6_offset, pname_len,
+ "Prefix name: %s", pname);
+ }
proto_item_set_text(trr, "%s: type %s, class %s, addr %d %s %s",
name,
type_name,