aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-dns.c
diff options
context:
space:
mode:
authormorriss <morriss@f5534014-38df-0310-8fa8-9805f1628bb7>2011-01-07 15:59:26 +0000
committermorriss <morriss@f5534014-38df-0310-8fa8-9805f1628bb7>2011-01-07 15:59:26 +0000
commit784b5137468b0d0f5a54b746e752eb56c2ee4cdc (patch)
tree7869f9629f13193de9fd3b69cf9d29ee0fa0d740 /epan/dissectors/packet-dns.c
parent93a3ee2110cdcd2e1c181e4750f642c44e800690 (diff)
Fix the fuzz failure in https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5554 :
Don't assume that g_strsplit() found and returned 3 strings. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35418 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/dissectors/packet-dns.c')
-rw-r--r--epan/dissectors/packet-dns.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/epan/dissectors/packet-dns.c b/epan/dissectors/packet-dns.c
index 8173e83313..00b71a29dd 100644
--- a/epan/dissectors/packet-dns.c
+++ b/epan/dissectors/packet-dns.c
@@ -981,23 +981,25 @@ add_rr_to_tree(proto_item *trr, int rr_type, tvbuff_t *tvb, int offset,
rr_tree = proto_item_add_subtree(trr, rr_type);
if(type == T_SRV) {
- srv_rr_info = g_strsplit(name, ".", 3);
+ srv_rr_info = g_strsplit(name, ".", 3);
- /* The + 1 on the strings is to skip the leading '_' */
-
- proto_tree_add_string(rr_tree, hf_dns_srv_service, tvb, offset,
- namelen, srv_rr_info[0]+1);
+ /* The + 1 on the strings is to skip the leading '_' */
- proto_tree_add_string(rr_tree, hf_dns_srv_proto, tvb, offset,
- namelen, srv_rr_info[1]+1);
+ proto_tree_add_string(rr_tree, hf_dns_srv_service, tvb, offset,
+ namelen, srv_rr_info[0]+1);
- proto_tree_add_string(rr_tree, hf_dns_srv_name, tvb, offset,
- namelen, srv_rr_info[2]);
+ if (srv_rr_info[1]) {
+ proto_tree_add_string(rr_tree, hf_dns_srv_proto, tvb, offset,
+ namelen, srv_rr_info[1]+1);
- g_strfreev(srv_rr_info);
+ if (srv_rr_info[2])
+ proto_tree_add_string(rr_tree, hf_dns_srv_name, tvb, offset,
+ namelen, srv_rr_info[2]);
+ }
+
+ g_strfreev(srv_rr_info);
} else {
- proto_tree_add_string(rr_tree, hf_dns_rr_name, tvb, offset,
- namelen, name);
+ proto_tree_add_string(rr_tree, hf_dns_rr_name, tvb, offset, namelen, name);
}
offset += namelen;