aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorDario Lombardo <lomato@gmail.com>2017-01-04 15:53:56 +0100
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2017-01-19 09:31:37 +0000
commitc397adda8a7af8374ba1355f8c221f48abfac42a (patch)
tree6ebe3eb7204ceab9ffe93036f58066abcdc9bbab /epan
parenta056b685760340e2a3d83014f618ba567fc8355b (diff)
dns: change get_dns_name to return consumed bytes + actual name len.
Because of the DNS name encoding, the consumed bytes in the tvb and the length of the string of the dns name can be different. We need to handle them separately for the purpose they are. Moreover the name string can contain null bytes, then we can't rely on strlen() but we need the actual length. Subsequent calls to proto_tree_add_string() will require to pass the string to format_text() in order have non-printable characters printed. Bug: 13289 Change-Id: I6d0b295867ece265f8995f82da2c629992aeb703 Reviewed-on: https://code.wireshark.org/review/19539 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Petri-Dish: Dario Lombardo <lomato@gmail.com> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/asn1/ldap/packet-ldap-template.c5
-rw-r--r--epan/dissectors/packet-bootp.c23
-rw-r--r--epan/dissectors/packet-dns.c319
-rw-r--r--epan/dissectors/packet-dns.h4
-rw-r--r--epan/dissectors/packet-icmpv6.c23
-rw-r--r--epan/dissectors/packet-ldap.c9
-rw-r--r--epan/dissectors/packet-lwres.c38
-rw-r--r--epan/dissectors/packet-nbt.c8
-rw-r--r--epan/dissectors/packet-smb-common.c6
9 files changed, 228 insertions, 207 deletions
diff --git a/epan/dissectors/asn1/ldap/packet-ldap-template.c b/epan/dissectors/asn1/ldap/packet-ldap-template.c
index f635be702a..d9caff5b6c 100644
--- a/epan/dissectors/asn1/ldap/packet-ldap-template.c
+++ b/epan/dissectors/asn1/ldap/packet-ldap-template.c
@@ -1308,10 +1308,11 @@ int dissect_mscldap_string(tvbuff_t *tvb, int offset, char *str, int max_len, gb
{
int compr_len;
const guchar *name;
+ guint name_len;
/* The name data MUST start at offset 0 of the tvb */
- compr_len = expand_dns_name(tvb, offset, max_len, 0, &name);
- g_strlcpy(str, name, max_len);
+ compr_len = get_dns_name(tvb, offset, max_len, 0, &name, &name_len);
+ g_strlcpy(str, name, name_len);
return offset + compr_len;
}
diff --git a/epan/dissectors/packet-bootp.c b/epan/dissectors/packet-bootp.c
index c9b204545a..8cb24c3641 100644
--- a/epan/dissectors/packet-bootp.c
+++ b/epan/dissectors/packet-bootp.c
@@ -124,6 +124,7 @@
#include <epan/expert.h>
#include <epan/uat.h>
#include <epan/oui.h>
+#include <epan/strutil.h>
#include <wsutil/str_util.h>
#include <wsutil/strtoi.h>
void proto_register_bootp(void);
@@ -1756,6 +1757,7 @@ bootp_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, proto_item
guint8 s_option;
guint8 s_len;
const guchar *dns_name;
+ guint dns_name_len;
gboolean option_handled = TRUE;
struct basic_types_hfs default_hfs = {
@@ -2360,9 +2362,9 @@ bootp_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, proto_item
proto_tree_add_item(v_tree, hf_bootp_fqdn_rcode2, tvb, optoff+2, 1, ENC_BIG_ENDIAN);
if (optlen > 3) {
if (fqdn_flags & F_FQDN_E) {
- get_dns_name(tvb, optoff+3, optlen-3, optoff+3, &dns_name);
+ get_dns_name(tvb, optoff+3, optlen-3, optoff+3, &dns_name, &dns_name_len);
proto_tree_add_string(v_tree, hf_bootp_fqdn_name,
- tvb, optoff+3, optlen-3, dns_name);
+ tvb, optoff+3, optlen-3, format_text(dns_name, dns_name_len));
} else {
proto_tree_add_item(v_tree, hf_bootp_fqdn_asciiname,
tvb, optoff+3, optlen-3, ENC_ASCII|ENC_NA);
@@ -2603,7 +2605,8 @@ bootp_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, proto_item
while (offset < tvb_reported_length(rfc3396_dns_domain_search_list.tvb_composite)) {
/* 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, offset, tvb_reported_length(rfc3396_dns_domain_search_list.tvb_composite), 0, &dns_name);
+ consumedx = get_dns_name(rfc3396_dns_domain_search_list.tvb_composite, offset,
+ tvb_reported_length(rfc3396_dns_domain_search_list.tvb_composite), 0, &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(v_tree, hf_bootp_option_dhcp_dns_domain_search_list_fqdn, tvb, optoff + offset, consumedx, dns_name);
@@ -2667,14 +2670,15 @@ bootp_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, proto_item
while (offset < tvb_reported_length(rfc3396_sip_server.tvb_composite)) {
/* 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, offset, tvb_reported_length(rfc3396_sip_server.tvb_composite), 1 /* ignore enc */, &dns_name);
+ consumedx = get_dns_name(rfc3396_sip_server.tvb_composite, offset, tvb_reported_length(rfc3396_sip_server.tvb_composite),
+ 1 /* ignore enc */, &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(v_tree, hf_bootp_option_sip_server_name, tvb, optoff + offset, consumedx, dns_name);
} 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(v_tree, hf_bootp_option_sip_server_name, tvb, 0, 0, dns_name);
+ proto_tree_add_string(v_tree, hf_bootp_option_sip_server_name, tvb, 0, 0, format_text(dns_name, dns_name_len));
}
offset += consumedx;
}
@@ -5657,6 +5661,7 @@ dissect_packetcable_ietf_ccc(packet_info *pinfo, proto_item *v_ti, proto_tree *v
proto_item *vti;
int max_timer_val = 255;
const guchar *dns_name;
+ guint dns_name_len;
subopt = tvb_get_guint8(tvb, suboptoff);
suboptoff++;
@@ -5699,8 +5704,8 @@ dissect_packetcable_ietf_ccc(packet_info *pinfo, proto_item *v_ti, proto_tree *v
switch (prov_type) {
case 0:
- get_dns_name(tvb, suboptoff, subopt_len, suboptoff, &dns_name);
- proto_item_append_text(vti, "%s (%u byte%s)", dns_name,
+ get_dns_name(tvb, suboptoff, subopt_len, suboptoff, &dns_name, &dns_name_len);
+ proto_item_append_text(vti, "%s (%u byte%s)", format_text(dns_name, dns_name_len),
subopt_len - 1, plurality(subopt_len, "", "s") );
break;
@@ -5757,8 +5762,8 @@ dissect_packetcable_ietf_ccc(packet_info *pinfo, proto_item *v_ti, proto_tree *v
break;
case PKT_CCC_KRB_REALM: /* String values */
- get_dns_name(tvb, suboptoff, subopt_len, suboptoff, &dns_name);
- proto_item_append_text(vti, "%s (%u byte%s)", dns_name,
+ get_dns_name(tvb, suboptoff, subopt_len, suboptoff, &dns_name, &dns_name_len);
+ proto_item_append_text(vti, "%s (%u byte%s)", format_text(dns_name, dns_name_len),
subopt_len, plurality(subopt_len, "", "s") );
suboptoff += subopt_len;
break;
diff --git a/epan/dissectors/packet-dns.c b/epan/dissectors/packet-dns.c
index 281d7b9268..53ae14462c 100644
--- a/epan/dissectors/packet-dns.c
+++ b/epan/dissectors/packet-dns.c
@@ -1112,7 +1112,7 @@ qname_labels_count(const guchar* name, guint name_len)
if (name_len > 1) {
/* it was not a Zero-length name */
- for (i = 0; i < strlen(name); i++) {
+ for (i = 0; i < name_len; i++) {
if (name[i] == '.')
labels++;
}
@@ -1128,7 +1128,7 @@ qname_labels_count(const guchar* name, guint name_len)
*/
int
expand_dns_name(tvbuff_t *tvb, int offset, int max_len, int dns_data_offset,
- const guchar **name)
+ const guchar **name, guint* name_len)
{
int start_offset = offset;
guchar *np;
@@ -1147,6 +1147,7 @@ expand_dns_name(tvbuff_t *tvb, int offset, int max_len, int dns_data_offset,
maxname=MAXDNAME;
np=(guchar *)wmem_alloc(wmem_packet_scope(), maxname);
*name=np;
+ (*name_len) = 0;
maxname--; /* reserve space for the trailing '\0' */
for (;;) {
@@ -1167,6 +1168,7 @@ expand_dns_name(tvbuff_t *tvb, int offset, int max_len, int dns_data_offset,
/* Not the first component - put in a '.'. */
if (maxname > 0) {
*np++ = '.';
+ (*name_len)++;
maxname--;
}
}
@@ -1176,6 +1178,7 @@ expand_dns_name(tvbuff_t *tvb, int offset, int max_len, int dns_data_offset,
}
if (maxname > 0) {
*np++ = tvb_get_guint8(tvb, offset);
+ (*name_len)++;
maxname--;
}
component_len--;
@@ -1296,17 +1299,20 @@ expand_dns_name(tvbuff_t *tvb, int offset, int max_len, int dns_data_offset,
return len;
}
+/* return the bytes in the tvb consumed by the function. The converted string (that
+ can contain null bytes, is written in name and its length in name_len. */
int
get_dns_name(tvbuff_t *tvb, int offset, int max_len, int dns_data_offset,
- const guchar **name)
+ const guchar **name, guint* name_len)
{
int len;
- len = expand_dns_name(tvb, offset, max_len, dns_data_offset, name);
+ len = expand_dns_name(tvb, offset, max_len, dns_data_offset, name, name_len);
/* Zero-length name means "root server" */
- if (**name == '\0') {
+ if (**name == '\0' && len == 1) {
*name="<Root>";
+ *name_len = (guint)strlen(*name);
}
return len;
@@ -1314,30 +1320,19 @@ get_dns_name(tvbuff_t *tvb, int offset, int max_len, int dns_data_offset,
static int
get_dns_name_type_class(tvbuff_t *tvb, int offset, int dns_data_offset,
- const guchar **name_ret, int *name_len_ret, int *type_ret, int *class_ret)
+ const guchar **name, int *name_len, int *type, int *dns_class)
{
- int len;
- int name_len;
- int type;
- int dns_class;
int start_offset = offset;
- /* XXX Fix data length */
- name_len = get_dns_name(tvb, offset, 0, dns_data_offset, name_ret);
- offset += name_len;
+ offset += get_dns_name(tvb, offset, 0, dns_data_offset, name, name_len);
- type = tvb_get_ntohs(tvb, offset);
+ *type = tvb_get_ntohs(tvb, offset);
offset += 2;
- dns_class = tvb_get_ntohs(tvb, offset);
+ *dns_class = tvb_get_ntohs(tvb, offset);
offset += 2;
- *type_ret = type;
- *class_ret = dns_class;
- *name_len_ret = name_len;
-
- len = offset - start_offset;
- return len;
+ return offset - start_offset;
}
static double
@@ -1390,7 +1385,7 @@ static int
dissect_dns_query(tvbuff_t *tvb, int offset, int dns_data_offset,
packet_info *pinfo, proto_tree *dns_tree, gboolean is_mdns)
{
- int len;
+ int used_bytes;
const guchar *name;
gchar *name_out;
int name_len;
@@ -1405,7 +1400,7 @@ dissect_dns_query(tvbuff_t *tvb, int offset, int dns_data_offset,
data_start = offset;
- len = get_dns_name_type_class(tvb, offset, dns_data_offset, &name, &name_len,
+ used_bytes = get_dns_name_type_class(tvb, offset, dns_data_offset, &name, &name_len,
&type, &dns_class);
if (is_mdns) {
@@ -1422,29 +1417,30 @@ dissect_dns_query(tvbuff_t *tvb, int offset, int dns_data_offset,
* The name might contain octets that aren't printable characters,
* format it for display.
*/
- name_out = format_text(name, strlen(name));
+ name_out = format_text(name, name_len);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s %s", type_name, name_out);
if (is_mdns) {
col_append_fstr(pinfo->cinfo, COL_INFO, ", \"%s\" question", qu ? "QU" : "QM");
}
if (dns_tree != NULL) {
- q_tree = proto_tree_add_subtree_format(dns_tree, tvb, offset, len, ett_dns_qd, &tq, "%s: type %s, class %s",
+ q_tree = proto_tree_add_subtree_format(dns_tree, tvb, offset, used_bytes, ett_dns_qd, &tq, "%s: type %s, class %s",
name_out, type_name, val_to_str_const(dns_class, dns_classes, "Unknown"));
if (is_mdns) {
proto_item_append_text(tq, ", \"%s\" question", qu ? "QU" : "QM");
}
- proto_tree_add_string(q_tree, hf_dns_qry_name, tvb, offset, name_len, name);
+ /* The number of used bytes for qname is the total used bytes minus 2 bytes for qtype and 2 bytes for qclass */
+ proto_tree_add_string(q_tree, hf_dns_qry_name, tvb, offset, used_bytes - 4, name_out);
- tq = proto_tree_add_uint(q_tree, hf_dns_qry_name_len, tvb, offset, name_len, name_len > 1 ? (guint32)strlen(name) : 0);
+ tq = proto_tree_add_uint(q_tree, hf_dns_qry_name_len, tvb, offset, name_len, name_len > 1 ? name_len : 0);
PROTO_ITEM_SET_GENERATED(tq);
labels = qname_labels_count(name, name_len);
tq = proto_tree_add_uint(q_tree, hf_dns_count_labels, tvb, offset, name_len, labels);
PROTO_ITEM_SET_GENERATED(tq);
- offset += name_len;
+ offset += used_bytes - 4;
proto_tree_add_item(q_tree, hf_dns_qry_type, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
@@ -1459,10 +1455,10 @@ dissect_dns_query(tvbuff_t *tvb, int offset, int dns_data_offset,
offset += 2;
}
- if (data_start + len != offset) {
+ if (data_start + used_bytes != offset) {
/* Add expert info ? (about incorrect len...)*/
}
- return len;
+ return used_bytes;
}
@@ -1736,7 +1732,6 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
proto_tree *dns_tree, packet_info *pinfo,
gboolean is_mdns)
{
- int len;
const guchar *name;
gchar *name_out;
int name_len;
@@ -1751,15 +1746,17 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
gushort data_len;
proto_tree *rr_tree = NULL;
proto_item *trr = NULL;
+ guint used_bytes;
data_start = data_offset = offsetx;
cur_offset = offsetx;
- len = get_dns_name_type_class(tvb, offsetx, dns_data_offset, &name, &name_len,
+ used_bytes = get_dns_name_type_class(tvb, offsetx, dns_data_offset, &name, &name_len,
&dns_type, &dns_class);
- data_offset += len;
- cur_offset += len;
+ /* The offset if the total used bytes minus 2 bytes for qtype and 2 bytes for qclass */
+ data_offset += used_bytes;
+ cur_offset += used_bytes;
if (is_mdns) {
/* Split the FLUSH flag and the class */
flush = dns_class & C_FLUSH;
@@ -1774,6 +1771,7 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
cur_offset += 4;
data_len = tvb_get_ntohs(tvb, data_offset);
+
data_offset += 2;
cur_offset += 2;
@@ -1787,19 +1785,19 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
* The name might contain octets that aren't printable characters,
* format it for display.
*/
- name_out = format_text(name, strlen(name));
+ name_out = format_text(name, name_len);
if (dns_type != T_OPT) {
rr_tree = proto_tree_add_subtree_format(dns_tree, tvb, offsetx,
(data_offset - data_start) + data_len,
ett_dns_rr, &trr, "%s: type %s, class %s",
name_out, type_name, class_name);
- add_rr_to_tree(rr_tree, tvb, offsetx, name, name_len,
+ add_rr_to_tree(rr_tree, tvb, offsetx, name, used_bytes - 4,
dns_type, pinfo, is_mdns);
} else {
rr_tree = proto_tree_add_subtree_format(dns_tree, tvb, offsetx,
(data_offset - data_start) + data_len,
ett_dns_rr, &trr, "%s: type %s", name_out, type_name);
- add_opt_rr_to_tree(rr_tree, tvb, offsetx, name, name_len, is_mdns);
+ add_opt_rr_to_tree(rr_tree, tvb, offsetx, name, used_bytes - 4, is_mdns);
}
if (is_mdns && flush) {
proto_item_append_text(trr, ", cache flush");
@@ -1836,11 +1834,11 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
const guchar *ns_name;
int ns_name_len;
- ns_name_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &ns_name);
- name_out = format_text(ns_name, strlen(ns_name));
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &ns_name, &ns_name_len);
+ name_out = format_text(ns_name, ns_name_len);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name_out);
proto_item_append_text(trr, ", ns %s", name_out);
- proto_tree_add_string(rr_tree, hf_dns_ns, tvb, cur_offset, ns_name_len, name_out);
+ proto_tree_add_string(rr_tree, hf_dns_ns, tvb, cur_offset, used_bytes, name_out);
}
break;
@@ -1853,8 +1851,9 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name);
- hostname_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &hostname_str);
- proto_tree_add_string(rr_tree, hf_dns_md, tvb, cur_offset, hostname_len, hostname_str);
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &hostname_str, &hostname_len);
+ name_out = format_text(hostname_str, hostname_len);
+ proto_tree_add_string(rr_tree, hf_dns_md, tvb, cur_offset, used_bytes, name_out);
}
break;
@@ -1865,10 +1864,11 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
const guchar *hostname_str;
- col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name);
+ col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name);
- hostname_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &hostname_str);
- proto_tree_add_string(rr_tree, hf_dns_mf, tvb, cur_offset, hostname_len, hostname_str);
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &hostname_str, &hostname_len);
+ name_out = format_text(hostname_str, hostname_len);
+ proto_tree_add_string(rr_tree, hf_dns_mf, tvb, cur_offset, used_bytes, name_out);
}
break;
@@ -1878,11 +1878,11 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
const guchar *cname;
int cname_len;
- cname_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &cname);
- name_out = format_text(cname, strlen(cname));
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &cname, &cname_len);
+ name_out = format_text(cname, cname_len);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name_out);
proto_item_append_text(trr, ", cname %s", name_out);
- proto_tree_add_string(rr_tree, hf_dns_cname, tvb, cur_offset, cname_len, name_out);
+ proto_tree_add_string(rr_tree, hf_dns_cname, tvb, cur_offset, used_bytes, name_out);
}
break;
@@ -1894,21 +1894,19 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
int mname_len;
const guchar *rname;
int rname_len;
- proto_item *ti_soa;
+ proto_item *ti_soa;
- /* XXX Fix data length */
- mname_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &mname);
- name_out = format_text(mname, strlen(mname));
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &mname, &mname_len);
+ name_out = format_text(mname, mname_len);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name_out);
proto_item_append_text(trr, ", mname %s", name_out);
- proto_tree_add_string(rr_tree, hf_dns_soa_mname, tvb, cur_offset, mname_len, name_out);
- cur_offset += mname_len;
+ proto_tree_add_string(rr_tree, hf_dns_soa_mname, tvb, cur_offset, used_bytes, name_out);
+ cur_offset += used_bytes;
- /* XXX Fix data length */
- rname_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &rname);
- name_out = format_text(rname, strlen(rname));
- proto_tree_add_string(rr_tree, hf_dns_soa_rname, tvb, cur_offset, rname_len, name_out);
- cur_offset += rname_len;
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &rname, &rname_len);
+ name_out = format_text(rname, rname_len);
+ proto_tree_add_string(rr_tree, hf_dns_soa_rname, tvb, cur_offset, used_bytes, name_out);
+ cur_offset += used_bytes;
proto_tree_add_item(rr_tree, hf_dns_soa_serial_number, tvb, cur_offset, 4, ENC_BIG_ENDIAN);
cur_offset += 4;
@@ -1939,8 +1937,9 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name);
- hostname_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &hostname_str);
- proto_tree_add_string(rr_tree, hf_dns_mb, tvb, cur_offset, hostname_len, hostname_str);
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &hostname_str, &hostname_len);
+ name_out = format_text(hostname_str, hostname_len);
+ proto_tree_add_string(rr_tree, hf_dns_mb, tvb, cur_offset, used_bytes, name_out);
}
break;
@@ -1950,10 +1949,11 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
int hostname_len;
const guchar *hostname_str;
- col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name);
+ col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name);
- hostname_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &hostname_str);
- proto_tree_add_string(rr_tree, hf_dns_mg, tvb, cur_offset, hostname_len, hostname_str);
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &hostname_str, &hostname_len);
+ name_out = format_text(hostname_str, hostname_len);
+ proto_tree_add_string(rr_tree, hf_dns_mg, tvb, cur_offset, used_bytes, name_out);
}
break;
@@ -1965,8 +1965,9 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name);
- hostname_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &hostname_str);
- proto_tree_add_string(rr_tree, hf_dns_mr, tvb, cur_offset, hostname_len, hostname_str);
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &hostname_str, &hostname_len);
+ name_out = format_text(hostname_str, hostname_len);
+ proto_tree_add_string(rr_tree, hf_dns_mr, tvb, cur_offset, used_bytes, name_out);
}
break;
@@ -2051,12 +2052,11 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
const guchar *pname;
int pname_len;
- /* XXX Fix data length */
- pname_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &pname);
- name_out = format_text(pname, strlen(pname));
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &pname, &pname_len);
+ name_out = format_text(pname, pname_len);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name_out);
proto_item_append_text(trr, ", %s", name_out);
- proto_tree_add_string(rr_tree, hf_dns_ptr_domain_name, tvb, cur_offset, pname_len, name_out);
+ proto_tree_add_string(rr_tree, hf_dns_ptr_domain_name, tvb, cur_offset, used_bytes, name_out);
}
break;
@@ -2100,12 +2100,13 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name);
- rmailbx_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &rmailbx_str);
- proto_tree_add_string(rr_tree, hf_dns_minfo_r_mailbox, tvb, cur_offset, rmailbx_len, rmailbx_str);
- cur_offset += rmailbx_len;
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &rmailbx_str, &rmailbx_len);
+ name_out = format_text(rmailbx_str, rmailbx_len);
+ proto_tree_add_string(rr_tree, hf_dns_minfo_r_mailbox, tvb, cur_offset, used_bytes, name_out);
+ cur_offset += used_bytes;
- emailbx_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &emailbx_str);
- proto_tree_add_string(rr_tree, hf_dns_minfo_e_mailbox, tvb, cur_offset, emailbx_len, emailbx_str);
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &emailbx_str, &emailbx_len);
+ proto_tree_add_string(rr_tree, hf_dns_minfo_e_mailbox, tvb, cur_offset, used_bytes, name_out);
}
break;
@@ -2117,15 +2118,15 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
int mx_name_len;
preference = tvb_get_ntohs(tvb, cur_offset);
- /* XXX Fix data length */
- mx_name_len = get_dns_name(tvb, cur_offset + 2, 0, dns_data_offset, &mx_name);
- name_out = format_text(mx_name, strlen(mx_name));
+
+ used_bytes = get_dns_name(tvb, cur_offset + 2, 0, dns_data_offset, &mx_name, &mx_name_len);
+ name_out = format_text(mx_name, mx_name_len);
col_append_fstr(pinfo->cinfo, COL_INFO, " %u %s", preference, name_out);
proto_item_append_text(trr, ", preference %u, mx %s",
preference, name_out);
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, mx_name_len, name_out);
+ proto_tree_add_string(rr_tree, hf_dns_mx_mail_exchange, tvb, cur_offset, used_bytes, name_out);
/* cur_offset += mx_name_len; */
}
@@ -2161,12 +2162,14 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name);
- mbox_dname_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &mbox_dname);
- proto_tree_add_string(rr_tree, hf_dns_rp_mailbox, tvb, cur_offset, mbox_dname_len, mbox_dname);
- cur_offset += mbox_dname_len;
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &mbox_dname, &mbox_dname_len);
+ name_out = format_text(mbox_dname, mbox_dname_len);
+ proto_tree_add_string(rr_tree, hf_dns_rp_mailbox, tvb, cur_offset, used_bytes, name_out);
+ cur_offset += used_bytes;
- txt_dname_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &txt_dname);
- proto_tree_add_string(rr_tree, hf_dns_rp_txt_rr, tvb, cur_offset, txt_dname_len, txt_dname);
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &txt_dname, &txt_dname_len);
+ name_out = format_text(txt_dname, txt_dname_len);
+ proto_tree_add_string(rr_tree, hf_dns_rp_txt_rr, tvb, cur_offset, used_bytes, name_out);
}
break;
@@ -2178,12 +2181,13 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name);
- host_name_len = get_dns_name(tvb, cur_offset + 2, 0, dns_data_offset, &host_name);
+ used_bytes = get_dns_name(tvb, cur_offset + 2, 0, dns_data_offset, &host_name, &host_name_len);
+ name_out = format_text(host_name, host_name_len);
proto_tree_add_item(rr_tree, hf_dns_afsdb_subtype, tvb, cur_offset, 2, ENC_BIG_ENDIAN);
cur_offset += 2;
- proto_tree_add_string(rr_tree, hf_dns_afsdb_hostname, tvb, cur_offset, host_name_len, host_name);
+ proto_tree_add_string(rr_tree, hf_dns_afsdb_hostname, tvb, cur_offset, used_bytes, name_out);
}
break;
@@ -2240,12 +2244,13 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name);
- host_name_len = get_dns_name(tvb, cur_offset + 2, 0, dns_data_offset, &host_name);
+ used_bytes = get_dns_name(tvb, cur_offset + 2, 0, dns_data_offset, &host_name, &host_name_len);
+ name_out = format_text(host_name, host_name_len);
proto_tree_add_item(rr_tree, hf_dns_rt_preference, tvb, cur_offset, 2, ENC_BIG_ENDIAN);
cur_offset += 2;
- proto_tree_add_string(rr_tree, hf_dns_rt_intermediate_host, tvb, cur_offset, host_name_len, host_name);
+ proto_tree_add_string(rr_tree, hf_dns_rt_intermediate_host, tvb, cur_offset, used_bytes, name_out);
}
break;
@@ -2266,8 +2271,9 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name);
- nsap_ptr_owner_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &nsap_ptr_owner);
- proto_tree_add_string(rr_tree, hf_dns_nsap_ptr_owner, tvb, cur_offset, nsap_ptr_owner_len, nsap_ptr_owner);
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &nsap_ptr_owner, &nsap_ptr_owner_len);
+ name_out = format_text(nsap_ptr_owner, nsap_ptr_owner_len);
+ proto_tree_add_string(rr_tree, hf_dns_nsap_ptr_owner, tvb, cur_offset, used_bytes, name_out);
}
break;
@@ -2324,19 +2330,21 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
case T_PX: /* Pointer to X.400/RFC822 mapping info (26)*/
{
- int px_map822_len, px_mapx400_len;
+ guint px_map822_len, px_mapx400_len;
const guchar *px_map822_dnsname, *px_mapx400_dnsname;
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name);
proto_tree_add_item(rr_tree, hf_dns_px_preference, tvb, cur_offset, 2, ENC_BIG_ENDIAN);
cur_offset += 2;
- px_map822_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &px_map822_dnsname);
- proto_tree_add_string(rr_tree, hf_dns_px_map822, tvb, cur_offset, px_map822_len, px_map822_dnsname);
- cur_offset += px_map822_len;
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &px_map822_dnsname, &px_map822_len);
+ name_out = format_text(px_map822_dnsname, px_map822_len);
+ proto_tree_add_string(rr_tree, hf_dns_px_map822, tvb, cur_offset, used_bytes, name_out);
+ cur_offset += used_bytes;
- px_mapx400_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &px_mapx400_dnsname);
- proto_tree_add_string(rr_tree, hf_dns_px_mapx400, tvb, cur_offset, px_mapx400_len, px_mapx400_dnsname);
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &px_mapx400_dnsname, &px_mapx400_len);
+ name_out = format_text(px_mapx400_dnsname, px_mapx400_len);
+ proto_tree_add_string(rr_tree, hf_dns_px_mapx400, tvb, cur_offset, used_bytes, px_mapx400_dnsname);
/*cur_offset += px_mapx400_len;*/
}
break;
@@ -2441,16 +2449,14 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
const guchar *next_domain_name;
int next_domain_name_len;
-
- /* XXX Fix data length */
- next_domain_name_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset,
- &next_domain_name);
- name_out = format_text(next_domain_name, strlen(next_domain_name));
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset,
+ &next_domain_name, &next_domain_name_len);
+ name_out = format_text(next_domain_name, next_domain_name_len);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name_out);
proto_item_append_text(trr, ", next domain name %s", name_out);
- proto_tree_add_string(rr_tree, hf_dns_nxt_next_domain_name, tvb, cur_offset, next_domain_name_len, name_out);
- cur_offset += next_domain_name_len;
- rr_len -= next_domain_name_len;
+ proto_tree_add_string(rr_tree, hf_dns_nxt_next_domain_name, tvb, cur_offset, used_bytes, name_out);
+ cur_offset += used_bytes;
+ rr_len -= used_bytes;
dissect_type_bitmap_nxt(rr_tree, tvb, cur_offset, rr_len);
}
@@ -2477,11 +2483,10 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
port = tvb_get_ntohs(tvb, cur_offset);
cur_offset += 2;
- /* XXX Fix data length */
- target_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &target);
- name_out = format_text(target, strlen(target));
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &target, &target_len);
+ name_out = format_text(target, target_len);
- proto_tree_add_string(rr_tree, hf_dns_srv_target, tvb, cur_offset, target_len, name_out);
+ proto_tree_add_string(rr_tree, hf_dns_srv_target, tvb, cur_offset, used_bytes, name_out);
col_append_fstr(pinfo->cinfo, COL_INFO, " %u %u %u %s", priority, weight, port, name_out);
proto_item_append_text(trr,
@@ -2538,12 +2543,12 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
offset += regex_len;
/* Replacement */
- replacement_len = get_dns_name(tvb, offset, 0, dns_data_offset, &replacement);
- name_out = format_text(replacement, strlen(replacement));
+ used_bytes = get_dns_name(tvb, offset, 0, dns_data_offset, &replacement, &replacement_len);
+ name_out = format_text(replacement, replacement_len);
ti_len = proto_tree_add_uint(rr_tree, hf_dns_naptr_replacement_length, tvb, offset, 0, replacement_len);
PROTO_ITEM_SET_GENERATED(ti_len);
- proto_tree_add_string(rr_tree, hf_dns_naptr_replacement, tvb, offset, replacement_len, name_out);
+ proto_tree_add_string(rr_tree, hf_dns_naptr_replacement, tvb, offset, used_bytes, name_out);
col_append_fstr(pinfo->cinfo, COL_INFO, " %u %u %s", order, preference, flags);
@@ -2559,14 +2564,13 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
const guchar *kx_name;
int kx_name_len;
- /* XXX Fix data length */
- kx_name_len = get_dns_name(tvb, cur_offset + 2, 0, dns_data_offset, &kx_name);
- name_out = format_text(kx_name, strlen(kx_name));
+ used_bytes = get_dns_name(tvb, cur_offset + 2, 0, dns_data_offset, &kx_name, &kx_name_len);
+ name_out = format_text(kx_name, kx_name_len);
col_append_fstr(pinfo->cinfo, COL_INFO, " %u %s", tvb_get_ntohs(tvb, cur_offset), name_out);
proto_item_append_text(trr, ", preference %u, kx %s",
tvb_get_ntohs(tvb, cur_offset), name_out);
proto_tree_add_item(rr_tree, hf_dns_kx_preference, tvb, cur_offset, 2, ENC_BIG_ENDIAN);
- proto_tree_add_string(rr_tree, hf_dns_kx_key_exchange, tvb, cur_offset + 2, kx_name_len, name_out);
+ proto_tree_add_string(rr_tree, hf_dns_kx_key_exchange, tvb, cur_offset + 2, used_bytes, name_out);
}
break;
@@ -2622,14 +2626,13 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
}
if (pre_len > 0) {
- /* XXX Fix data length */
- pname_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset,
- &pname);
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset,
+ &pname, &pname_len);
} else {
- pname="";
+ pname = "";
pname_len = 0;
}
- name_out = format_text(pname, strlen(pname));
+ name_out = format_text(pname, pname_len);
set_address(&suffix_addr, AT_IPv6, 16, suffix.bytes);
col_append_fstr(pinfo->cinfo, COL_INFO, " %d %s %s",
@@ -2644,7 +2647,7 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
a6_offset += suf_octet_count;
}
if (pre_len > 0) {
- proto_tree_add_string(rr_tree, hf_dns_a6_prefix_name, tvb, a6_offset, pname_len, name_out);
+ proto_tree_add_string(rr_tree, hf_dns_a6_prefix_name, tvb, a6_offset, used_bytes, name_out);
}
proto_item_append_text(trr, ", addr %d %s %s",
pre_len,
@@ -2660,13 +2663,12 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
const guchar *dname;
int dname_len;
- /* XXX Fix data length */
- dname_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset,
- &dname);
- name_out = format_text(dname, strlen(dname));
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset,
+ &dname, &dname_len);
+ name_out = format_text(dname, dname_len);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name_out);
proto_item_append_text(trr, ", dname %s", name_out);
- proto_tree_add_string(rr_tree, hf_dns_dname, tvb, cur_offset, dname_len, name_out);
+ proto_tree_add_string(rr_tree, hf_dns_dname, tvb, cur_offset, used_bytes, name_out);
}
break;
@@ -2930,9 +2932,9 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
rr_len -= 16;
break;
case 3:
- /* XXX Fix data length */
- gw_name_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &gw);
- proto_tree_add_string(rr_tree, hf_dns_ipseckey_gateway_dns, tvb, cur_offset, gw_name_len, gw);
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &gw, &gw_name_len);
+ name_out = format_text(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;
@@ -2984,9 +2986,9 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
cur_offset += 2;
rr_len -= 2;
- /* XXX Fix data length */
- signer_name_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &signer_name);
- proto_tree_add_string(rr_tree, hf_dns_rrsig_signers_name, tvb, cur_offset, signer_name_len, signer_name);
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &signer_name, &signer_name_len);
+ name_out = format_text(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;
@@ -3003,15 +3005,14 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
const guchar *next_domain_name;
int next_domain_name_len;
- /* XXX Fix data length */
- next_domain_name_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset,
- &next_domain_name);
- name_out = format_text(next_domain_name, strlen(next_domain_name));
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset,
+ &next_domain_name, &next_domain_name_len);
+ name_out = format_text(next_domain_name, next_domain_name_len);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name_out);
proto_item_append_text(trr, ", next domain name %s", name_out);
- proto_tree_add_string(rr_tree, hf_dns_nsec_next_domain_name, tvb, cur_offset, next_domain_name_len, name_out);
- cur_offset += next_domain_name_len;
- rr_len -= next_domain_name_len;
+ proto_tree_add_string(rr_tree, hf_dns_nsec_next_domain_name, tvb, cur_offset, used_bytes, name_out);
+ cur_offset += used_bytes;
+ rr_len -= used_bytes;
dissect_type_bitmap(rr_tree, tvb, cur_offset, rr_len);
@@ -3189,10 +3190,11 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
rr_len -= pk_len;
while (rr_len > 1) {
- rendezvous_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &rend_server_dns_name);
- proto_tree_add_string(rr_tree, hf_dns_hip_rendezvous_server, tvb, cur_offset, rendezvous_len, rend_server_dns_name);
- cur_offset += rendezvous_len;
- rr_len -= rendezvous_len;
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &rend_server_dns_name, &rendezvous_len);
+ name_out = format_text(rend_server_dns_name, rendezvous_len);
+ proto_tree_add_string(rr_tree, hf_dns_hip_rendezvous_server, tvb, cur_offset, used_bytes, name_out);
+ cur_offset += used_bytes;
+ rr_len -= used_bytes;
}
}
@@ -3214,7 +3216,7 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
cur_offset += 4;
proto_tree_add_bitmask_with_flags(rr_tree, tvb, cur_offset,
- hf_dns_csync_flags, ett_dns_csdync_flags, dns_csync_flags, ENC_BIG_ENDIAN, BMT_NO_APPEND);
+ hf_dns_csync_flags, ett_dns_csdync_flags, dns_csync_flags, ENC_BIG_ENDIAN, BMT_NO_APPEND);
cur_offset += 2;
rr_len = data_len - (cur_offset - initial_offset);
@@ -3290,9 +3292,9 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
proto_tree_add_item(rr_tree, hf_dns_ilnp_locatorfqdn_preference, tvb, cur_offset, 2, ENC_BIG_ENDIAN);
cur_offset += 2;
- /* XXX Fix data length */
- lp_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &lp_str);
- proto_tree_add_string(rr_tree, hf_dns_ilnp_locatorfqdn, tvb, cur_offset, lp_len, lp_str);
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &lp_str, &lp_len);
+ name_out = format_text(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;*/
}
@@ -3329,10 +3331,10 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
proto_tree *key_tree;
proto_item *key_item;
- /* XXX Fix data length */
- tkey_algname_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &tkey_algname);
- proto_tree_add_string(rr_tree, hf_dns_tkey_algo_name, tvb, cur_offset, tkey_algname_len, tkey_algname);
- cur_offset += tkey_algname_len;
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &tkey_algname, &tkey_algname_len);
+ name_out = format_text(tkey_algname, tkey_algname_len);
+ proto_tree_add_string(rr_tree, hf_dns_tkey_algo_name, tvb, cur_offset, used_bytes, name_out);
+ cur_offset += used_bytes;
proto_tree_add_item(rr_tree, hf_dns_tkey_signature_inception, tvb, cur_offset, 4, ENC_BIG_ENDIAN);
cur_offset += 4;
@@ -3414,10 +3416,10 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
int tsig_algname_len;
proto_item *ti;
- /* XXX Fix data length */
- tsig_algname_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &tsig_algname);
- proto_tree_add_string(rr_tree, hf_dns_tsig_algorithm_name, tvb, cur_offset, tsig_algname_len, tsig_algname);
- cur_offset += tsig_algname_len;
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &tsig_algname, &tsig_algname_len);
+ name_out = format_text(tsig_algname, tsig_algname_len);
+ proto_tree_add_string(rr_tree, hf_dns_tsig_algorithm_name, tvb, cur_offset, used_bytes, name_out);
+ cur_offset += used_bytes;
ti = proto_tree_add_item(rr_tree, hf_dns_tsig_time_signed ,tvb, cur_offset, 6, ENC_NA);
if(tvb_get_ntohs(tvb, cur_offset)) /* Time High */
@@ -3560,10 +3562,9 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset,
proto_tree_add_item(rr_tree, hf_dns_winsr_cache_timeout, tvb, cur_offset, 4, ENC_BIG_ENDIAN);
cur_offset += 4;
- /* XXX Fix data length */
- dname_len = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &dname);
- name_out = format_text(dname, strlen(dname));
- proto_tree_add_string(rr_tree, hf_dns_winsr_name_result_domain, tvb, cur_offset, dname_len, name_out);
+ used_bytes = get_dns_name(tvb, cur_offset, 0, dns_data_offset, &dname, &dname_len);
+ name_out = format_text(dname, dname_len);
+ proto_tree_add_string(rr_tree, hf_dns_winsr_name_result_domain, tvb, cur_offset, used_bytes, name_out);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", name_out);
proto_item_append_text(trr, ", name result domain %s", name_out);
}
diff --git a/epan/dissectors/packet-dns.h b/epan/dissectors/packet-dns.h
index 7fb6bee25b..9f8b8344e0 100644
--- a/epan/dissectors/packet-dns.h
+++ b/epan/dissectors/packet-dns.h
@@ -27,9 +27,9 @@
extern const value_string dns_classes[];
-int expand_dns_name(tvbuff_t *, int, int, int, const guchar **);
+int expand_dns_name(tvbuff_t *, int, int, int, const guchar **, guint*);
/* Just like expand_dns_name, but pretty-prints empty names. */
-int get_dns_name(tvbuff_t *, int, int, int, const guchar **);
+int get_dns_name(tvbuff_t *, int, int, int, const guchar **, guint*);
#define MAXDNAME 1025 /* maximum domain name length */
diff --git a/epan/dissectors/packet-icmpv6.c b/epan/dissectors/packet-icmpv6.c
index 9e543df268..45e85a48d0 100644
--- a/epan/dissectors/packet-icmpv6.c
+++ b/epan/dissectors/packet-icmpv6.c
@@ -46,6 +46,7 @@
#include <epan/capture_dissectors.h>
#include <epan/proto_data.h>
#include <epan/ipv6.h>
+#include <epan/strutil.h>
#include "packet-ber.h"
#include "packet-dns.h"
@@ -1520,6 +1521,7 @@ dissect_icmpv6_nd_opt(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree
int opt_len;
int opt_offset;
tvbuff_t *opt_tvb;
+ guint used_bytes;
while ((int)tvb_reported_length(tvb) > offset) {
/* there are more options */
@@ -2287,10 +2289,10 @@ dissect_icmpv6_nd_opt(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree
opt_offset += padd_length;
break;
}
- dnssl_len = get_dns_name(tvb, opt_offset, 0, opt_offset, &dnssl_name);
- proto_tree_add_string(icmp6opt_tree, hf_icmpv6_opt_dnssl, tvb, opt_offset, dnssl_len, dnssl_name);
+ used_bytes = get_dns_name(tvb, opt_offset, 0, opt_offset, &dnssl_name, &dnssl_len);
+ proto_tree_add_string(icmp6opt_tree, hf_icmpv6_opt_dnssl, tvb, opt_offset, used_bytes, format_text(dnssl_name, dnssl_len));
proto_item_append_text(ti, " %s", dnssl_name);
- opt_offset += dnssl_len;
+ opt_offset += used_bytes;
}
break;
@@ -3390,6 +3392,7 @@ static int
dissect_nodeinfo(tvbuff_t *tvb, int ni_offset, packet_info *pinfo _U_, proto_tree *tree, guint8 icmp6_type, guint8 icmp6_code)
{
guint16 qtype;
+ guint used_bytes;
static const int * ni_flags[] = {
&hf_icmpv6_ni_flag_g,
&hf_icmpv6_ni_flag_s,
@@ -3430,8 +3433,9 @@ dissect_nodeinfo(tvbuff_t *tvb, int ni_offset, packet_info *pinfo _U_, proto_tre
case ICMP6_NI_SUBJ_FQDN: {
int fqdn_len;
const guchar *fqdn_name;
- fqdn_len = get_dns_name(tvb, ni_offset, 0, ni_offset, &fqdn_name);
- proto_tree_add_string(tree, hf_icmpv6_ni_query_subject_fqdn, tvb, ni_offset, fqdn_len, fqdn_name);
+ 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(fqdn_name, fqdn_len));
ni_offset += fqdn_len;
break;
}
@@ -3446,7 +3450,7 @@ dissect_nodeinfo(tvbuff_t *tvb, int ni_offset, packet_info *pinfo _U_, proto_tre
case NI_QTYPE_NOOP:
break;
case NI_QTYPE_NODENAME: {
- int node_len;
+ int node_name_len;
const guchar *node_name;
/* TTL */
proto_tree_add_item(tree, hf_icmpv6_ni_reply_node_ttl, tvb, ni_offset, 4, ENC_BIG_ENDIAN);
@@ -3461,9 +3465,10 @@ dissect_nodeinfo(tvbuff_t *tvb, int ni_offset, packet_info *pinfo _U_, proto_tre
break;
}
/* Node Name */
- node_len = get_dns_name(tvb, ni_offset, 0, ni_offset, &node_name);
- proto_tree_add_string(tree, hf_icmpv6_ni_reply_node_name, tvb, ni_offset, node_len, node_name);
- ni_offset += node_len;
+ used_bytes = get_dns_name(tvb, ni_offset, 0, ni_offset, &node_name, &node_name_len);
+ proto_tree_add_string(tree, hf_icmpv6_ni_reply_node_name, tvb, ni_offset, used_bytes,
+ format_text(node_name, node_name_len));
+ ni_offset += used_bytes;
}
break;
}
diff --git a/epan/dissectors/packet-ldap.c b/epan/dissectors/packet-ldap.c
index 02256b64fb..1fb1918446 100644
--- a/epan/dissectors/packet-ldap.c
+++ b/epan/dissectors/packet-ldap.c
@@ -4228,10 +4228,11 @@ int dissect_mscldap_string(tvbuff_t *tvb, int offset, char *str, int max_len, gb
{
int compr_len;
const guchar *name;
+ guint name_len;
/* The name data MUST start at offset 0 of the tvb */
- compr_len = expand_dns_name(tvb, offset, max_len, 0, &name);
- g_strlcpy(str, name, max_len);
+ compr_len = get_dns_name(tvb, offset, max_len, 0, &name, &name_len);
+ g_strlcpy(str, name, name_len);
return offset + compr_len;
}
@@ -5640,7 +5641,7 @@ void proto_register_ldap(void) {
NULL, HFILL }},
/*--- End of included file: packet-ldap-hfarr.c ---*/
-#line 2155 "./asn1/ldap/packet-ldap-template.c"
+#line 2156 "./asn1/ldap/packet-ldap-template.c"
};
/* List of subtrees */
@@ -5714,7 +5715,7 @@ void proto_register_ldap(void) {
&ett_ldap_T_warning,
/*--- End of included file: packet-ldap-ettarr.c ---*/
-#line 2169 "./asn1/ldap/packet-ldap-template.c"
+#line 2170 "./asn1/ldap/packet-ldap-template.c"
};
/* UAT for header fields */
static uat_field_t custom_attribute_types_uat_fields[] = {
diff --git a/epan/dissectors/packet-lwres.c b/epan/dissectors/packet-lwres.c
index 2ea66a1aff..d72ddc02c1 100644
--- a/epan/dissectors/packet-lwres.c
+++ b/epan/dissectors/packet-lwres.c
@@ -27,6 +27,7 @@
#include <epan/packet.h>
#include <epan/to_str.h>
+#include <epan/strutil.h>
#include "packet-dns.h"
@@ -473,7 +474,9 @@ static void dissect_a_records(tvbuff_t* tvb, proto_tree* tree,guint32 nrec,int o
static void dissect_srv_records(tvbuff_t* tvb, proto_tree* tree,guint32 nrec,int offset)
{
guint32 i, curr;
- guint16 /*len, namelen,*/ priority, weight, port, dlen;
+ guint16 /*len, namelen,*/ priority, weight, port;
+ guint dlen;
+ guint used_bytes;
const guchar *dname;
proto_item* srv_rec_tree, *rec_tree;
@@ -493,7 +496,7 @@ static void dissect_srv_records(tvbuff_t* tvb, proto_tree* tree,guint32 nrec,int
port = tvb_get_ntohs(tvb, curr + 6);
/*namelen = len - 8;*/
- dlen = get_dns_name(tvb, curr + 8, 0, curr + 8, &dname);
+ used_bytes = get_dns_name(tvb, curr + 8, 0, curr + 8, &dname, &dlen);
rec_tree = proto_tree_add_subtree_format(srv_rec_tree, tvb, curr, 6,
ett_srv_rec_item, NULL,
@@ -526,10 +529,10 @@ static void dissect_srv_records(tvbuff_t* tvb, proto_tree* tree,guint32 nrec,int
hf_srv_dname,
tvb,
curr + 8,
- dlen,
- dname);
+ used_bytes,
+ format_text(dname, dlen));
- curr+=(int)((sizeof(short)*4) + dlen);
+ curr+=(int)((sizeof(short)*4) + used_bytes);
}
@@ -539,7 +542,9 @@ static void dissect_mx_records(tvbuff_t* tvb, proto_tree* tree, guint32 nrec, in
{
guint i, curr;
- guint /*len, namelen,*/ priority, dlen;
+ guint priority;
+ guint dlen;
+ guint used_bytes;
const guchar *dname;
proto_tree* mx_rec_tree, *rec_tree;
@@ -554,10 +559,10 @@ static void dissect_mx_records(tvbuff_t* tvb, proto_tree* tree, guint32 nrec, in
for(i=0; i < nrec; i++)
{
/*len = tvb_get_ntohs(tvb, curr);*/
- priority = tvb_get_ntohs(tvb, curr + 2);
+ priority = tvb_get_ntohs(tvb, curr + 2);
/*namelen = len - 4;*/
- dlen = get_dns_name(tvb, curr + 4, 0, curr + 4, &dname);
+ 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);
@@ -574,10 +579,10 @@ static void dissect_mx_records(tvbuff_t* tvb, proto_tree* tree, guint32 nrec, in
hf_srv_dname,
tvb,
curr + 4,
- dlen,
- dname);
+ used_bytes,
+ format_text(dname, dlen));
- curr+=(int)((sizeof(short)*2) + dlen);
+ curr+=(int)((sizeof(short)*2) + used_bytes);
}
@@ -587,8 +592,9 @@ static void dissect_mx_records(tvbuff_t* tvb, proto_tree* tree, guint32 nrec, in
static void dissect_ns_records(tvbuff_t* tvb, proto_tree* tree, guint32 nrec, int offset)
{
guint i, curr;
- guint /*len, namelen,*/ dlen;
+ guint dlen;
const guchar *dname;
+ guint used_bytes;
proto_tree* ns_rec_tree, *rec_tree;
@@ -604,7 +610,7 @@ static void dissect_ns_records(tvbuff_t* tvb, proto_tree* tree, guint32 nrec, in
/*len = tvb_get_ntohs(tvb, curr);*/
/*namelen = len - 2;*/
- dlen = get_dns_name(tvb, curr + 2, 0, curr + 2, &dname);
+ 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);
@@ -612,9 +618,9 @@ static void dissect_ns_records(tvbuff_t* tvb, proto_tree* tree, guint32 nrec, in
hf_ns_dname,
tvb,
curr + 2,
- dlen,
- dname);
- curr+=(int)(sizeof(short) + dlen);
+ used_bytes,
+ format_text(dname, dlen));
+ curr+=(int)(sizeof(short) + used_bytes);
}
diff --git a/epan/dissectors/packet-nbt.c b/epan/dissectors/packet-nbt.c
index ab8342dd29..b62ec22b5a 100644
--- a/epan/dissectors/packet-nbt.c
+++ b/epan/dissectors/packet-nbt.c
@@ -347,11 +347,11 @@ get_nbns_name(tvbuff_t *tvb, int offset, int nbns_data_offset,
int name_type;
char *pname_ret;
size_t idx = 0;
+ guint used_bytes;
nbname_buf = (char *)wmem_alloc(wmem_packet_scope(), NBNAME_BUF_LEN);
nbname = nbname_buf;
- /* XXX Fix data len */
- name_len = get_dns_name(tvb, offset, 0, nbns_data_offset, &name);
+ used_bytes = get_dns_name(tvb, offset, 0, nbns_data_offset, &name, &name_len);
/* OK, now undo the first-level encoding. */
pname = &name[0];
@@ -417,7 +417,7 @@ get_nbns_name(tvbuff_t *tvb, int offset, int nbns_data_offset,
}
if (name_type_ret != NULL)
*name_type_ret = name_type;
- return name_len;
+ return used_bytes;
bad:
if (name_type_ret != NULL)
@@ -425,7 +425,7 @@ bad:
/* This is only valid because nbname is always assigned an error string
* before jumping to bad: Otherwise nbname wouldn't be \0 terminated */
g_snprintf(pname_ret, name_ret_len-(gulong)(pname_ret-name_ret), "%s", nbname);
- return name_len;
+ return used_bytes;
}
diff --git a/epan/dissectors/packet-smb-common.c b/epan/dissectors/packet-smb-common.c
index 204c08bfd6..aad6cf251f 100644
--- a/epan/dissectors/packet-smb-common.c
+++ b/epan/dissectors/packet-smb-common.c
@@ -26,6 +26,7 @@
#include "config.h"
#include <epan/packet.h>
+#include <epan/strutil.h>
#include "packet-smb-common.h"
#include "packet-dns.h"
@@ -125,11 +126,12 @@ int dissect_ms_compressed_string(tvbuff_t *tvb, proto_tree *tree, int offset, in
const char **data)
{
int compr_len;
+ guint str_len;
const guchar *str = NULL;
/* The name data MUST start at offset 0 of the tvb */
- compr_len = expand_dns_name(tvb, offset, MAX_UNICODE_STR_LEN+3+1, 0, &str);
- proto_tree_add_string(tree, hf_index, tvb, offset, compr_len, str);
+ compr_len = get_dns_name(tvb, offset, MAX_UNICODE_STR_LEN+3+1, 0, &str, &str_len);
+ proto_tree_add_string(tree, hf_index, tvb, offset, compr_len, format_text(str, str_len));
if (data)
*data = str;