get_dns_name: fixup some missing change introduced with c397adda8a

Following commit c397adda8a there was some missing change

* Some `cur_offset += name_len` instead of `cur_offset += used_bytes`
* Some missing format_text

I took a look at the code after observing a bug with RRSIG record.
The signature in RRSIG was dissecting with some strange offset.

You can easily generate some pcap with those commands

delv @1.1.1.1 A www.cloudflare.com
and/or
dig @1.1.1.1 +dnssec www.cloudflare.com

Change-Id: Ibd6a6248b7497b8409d7797dc320035c8c2d1ed8
Reviewed-on: https://code.wireshark.org/review/36080
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Jeremiejig 2020-02-11 22:59:28 +01:00 committed by Anders Broman
parent c129c28d3a
commit 18a7e64c85
4 changed files with 22 additions and 15 deletions

View File

@ -2772,6 +2772,7 @@ static int
dissect_dhcpopt_dhcp_domain_search(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
int length = tvb_reported_length(tvb);
gchar *name_out;
const gchar *dns_name;
guint dns_name_len;
@ -2808,12 +2809,13 @@ dissect_dhcpopt_dhcp_domain_search(tvbuff_t *tvb, packet_info *pinfo _U_, proto_
/* use the get_dns_name method that manages all techniques of RFC 1035 (compression pointer and so on) */
consumedx = get_dns_name(rfc3396_dns_domain_search_list.tvb_composite, composite_offset,
tvb_reported_length(rfc3396_dns_domain_search_list.tvb_composite), 0, &dns_name, &dns_name_len);
name_out = format_text(wmem_packet_scope(), dns_name, dns_name_len);
if (rfc3396_dns_domain_search_list.total_number_of_block == 1) {
/* RFC 3396 is not used, so we can easily link the fqdn with v_tree. */
proto_tree_add_string(tree, hf_dhcp_option_dhcp_dns_domain_search_list_fqdn, tvb, composite_offset, consumedx, dns_name);
proto_tree_add_string(tree, hf_dhcp_option_dhcp_dns_domain_search_list_fqdn, tvb, composite_offset, consumedx, name_out);
} else {
/* RFC 3396 is used, so the option is split into several option 119. We don't link fqdn with v_tree. */
proto_tree_add_string(tree, hf_dhcp_option_dhcp_dns_domain_search_list_fqdn, tvb, 0, 0, dns_name);
proto_tree_add_string(tree, hf_dhcp_option_dhcp_dns_domain_search_list_fqdn, tvb, 0, 0, name_out);
}
composite_offset += consumedx;
}
@ -2829,6 +2831,7 @@ dissect_dhcpopt_sip_servers(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
int length = tvb_reported_length(tvb);
const gchar *dns_name;
guint dns_name_len;
gchar *name_out;
/* Encoding Long Options in the Dynamic Host Configuration Protocol (DHCPv4) (RFC 3396) */
/* Domain Names - Implementation And Specification (RFC 1035) */
@ -2880,13 +2883,14 @@ dissect_dhcpopt_sip_servers(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* use the get_dns_name method that manages all techniques of RFC 1035 (compression pointer and so on) */
consumedx = get_dns_name(rfc3396_sip_server.tvb_composite, composite_offset, tvb_reported_length(rfc3396_sip_server.tvb_composite),
1 /* ignore enc */, &dns_name, &dns_name_len);
name_out = format_text(wmem_packet_scope(), dns_name, dns_name_len);
if (rfc3396_sip_server.total_number_of_block == 1) {
/* RFC 3396 is not used, so we can easily link the fqdn with v_tree. */
proto_tree_add_string(tree, hf_dhcp_option_sip_server_name, tvb, composite_offset, consumedx, dns_name);
proto_tree_add_string(tree, hf_dhcp_option_sip_server_name, tvb, composite_offset, consumedx, name_out);
} else {
/* RFC 3396 is used, so the option is split into several option 120. We don't link fqdn with v_tree. */
proto_tree_add_string(tree, hf_dhcp_option_sip_server_name, tvb, 0, 0, format_text(wmem_packet_scope(), dns_name, dns_name_len));
proto_tree_add_string(tree, hf_dhcp_option_sip_server_name, tvb, 0, 0, name_out);
}
composite_offset += consumedx;
}

View File

@ -2195,6 +2195,7 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
cur_offset += used_bytes;
used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &emailbx_str, &emailbx_len);
name_out = format_text(wmem_packet_scope(), emailbx_str, emailbx_len);
proto_tree_add_string(rr_tree, hf_dns_minfo_e_mailbox, tvb, cur_offset, used_bytes, name_out);
}
break;
@ -2215,7 +2216,7 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
proto_tree_add_item(rr_tree, hf_dns_mx_preference, tvb, cur_offset, 2, ENC_BIG_ENDIAN);
cur_offset += 2;
proto_tree_add_string(rr_tree, hf_dns_mx_mail_exchange, tvb, cur_offset, used_bytes, name_out);
/* cur_offset += mx_name_len; */
/* cur_offset += used_bytes; */
}
break;
@ -2416,7 +2417,7 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &px_mapx400_dnsname, &px_mapx400_len);
name_out = format_text(wmem_packet_scope(), px_mapx400_dnsname, px_mapx400_len);
proto_tree_add_string(rr_tree, hf_dns_px_mapx400, tvb, cur_offset, used_bytes, name_out);
/*cur_offset += px_mapx400_len;*/
/*cur_offset += used_bytes;*/
}
break;
@ -3025,8 +3026,8 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
name_out = format_text(wmem_packet_scope(), gw, gw_name_len);
proto_tree_add_string(rr_tree, hf_dns_ipseckey_gateway_dns, tvb, cur_offset, used_bytes, name_out);
cur_offset += gw_name_len;
rr_len -= gw_name_len;
cur_offset += used_bytes;
rr_len -= used_bytes;
}
break;
@ -3079,8 +3080,8 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &signer_name, &signer_name_len);
name_out = format_text(wmem_packet_scope(), signer_name, signer_name_len);
proto_tree_add_string(rr_tree, hf_dns_rrsig_signers_name, tvb, cur_offset, used_bytes, name_out);
cur_offset += signer_name_len;
rr_len -= signer_name_len;
cur_offset += used_bytes;
rr_len -= used_bytes;
if (rr_len != 0) {
proto_tree_add_item(rr_tree, hf_dns_rrsig_signature, tvb, cur_offset, rr_len, ENC_NA);
@ -3359,7 +3360,7 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &lp_str, &lp_len);
name_out = format_text(wmem_packet_scope(), lp_str, lp_len);
proto_tree_add_string(rr_tree, hf_dns_ilnp_locatorfqdn, tvb, cur_offset, used_bytes, name_out);
/*cur_offset += lp_len;*/
/*cur_offset += used_bytes;*/
}
break;

View File

@ -3500,7 +3500,7 @@ dissect_nodeinfo(tvbuff_t *tvb, int ni_offset, packet_info *pinfo _U_, proto_tre
used_bytes = get_dns_name(tvb, ni_offset, 0, ni_offset, &fqdn_name, &fqdn_len);
proto_tree_add_string(tree, hf_icmpv6_ni_query_subject_fqdn, tvb, ni_offset, used_bytes,
format_text(wmem_packet_scope(), fqdn_name, fqdn_len));
ni_offset += fqdn_len;
ni_offset += used_bytes;
break;
}
case ICMP6_NI_SUBJ_IPV4: {

View File

@ -489,7 +489,7 @@ static void dissect_srv_records(tvbuff_t* tvb, proto_tree* tree,guint32 nrec,int
rec_tree = proto_tree_add_subtree_format(srv_rec_tree, tvb, curr, 6,
ett_srv_rec_item, NULL,
"SRV record:pri=%d,w=%d,port=%d,dname=%s",
priority, weight, port, dname);
priority, weight, port, format_text(wmem_packet_scope(), dname, dlen));
proto_tree_add_uint(rec_tree,
hf_srv_prio,
@ -553,7 +553,8 @@ static void dissect_mx_records(tvbuff_t* tvb, proto_tree* tree, guint32 nrec, in
used_bytes = get_dns_name(tvb, curr + 4, 0, curr + 4, &dname, &dlen);
rec_tree = proto_tree_add_subtree_format(mx_rec_tree, tvb, curr,6,ett_mx_rec_item,NULL,
"MX record: pri=%d,dname=%s", priority,dname);
"MX record: pri=%d,dname=%s", priority,
format_text(wmem_packet_scope(), dname, dlen));
proto_tree_add_item(rec_tree,
@ -600,7 +601,8 @@ static void dissect_ns_records(tvbuff_t* tvb, proto_tree* tree, guint32 nrec, in
used_bytes = get_dns_name(tvb, curr + 2, 0, curr + 2, &dname, &dlen);
rec_tree = proto_tree_add_subtree_format(ns_rec_tree, tvb, curr,4, ett_ns_rec_item, NULL, "NS record: dname=%s",dname);
rec_tree = proto_tree_add_subtree_format(ns_rec_tree, tvb, curr,4, ett_ns_rec_item, NULL, "NS record: dname=%s",
format_text(wmem_packet_scope(), dname, dlen));
proto_tree_add_string(rec_tree,
hf_ns_dname,