diff options
author | Dario Lombardo <lomato@gmail.com> | 2017-01-04 15:53:56 +0100 |
---|---|---|
committer | Alexis La Goutte <alexis.lagoutte@gmail.com> | 2017-01-19 09:31:37 +0000 |
commit | c397adda8a7af8374ba1355f8c221f48abfac42a (patch) | |
tree | 6ebe3eb7204ceab9ffe93036f58066abcdc9bbab /epan/dissectors/packet-smb-common.c | |
parent | a056b685760340e2a3d83014f618ba567fc8355b (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/dissectors/packet-smb-common.c')
-rw-r--r-- | epan/dissectors/packet-smb-common.c | 6 |
1 files changed, 4 insertions, 2 deletions
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; |