diff options
author | Martin Kaiser <wireshark@kaiser.cx> | 2014-07-29 22:14:53 +0200 |
---|---|---|
committer | Martin Kaiser <wireshark@kaiser.cx> | 2014-07-29 21:49:10 +0000 |
commit | 9d0e4f6fdb2ed940b625a8b32707027e6f021a95 (patch) | |
tree | 7bcad764661273a827c6c9806048e7e15379f8fa /epan/dissectors/packet-tftp.c | |
parent | 5dd7cfeed2de61369e1bec605bb94ed242a3b802 (diff) | |
download | wireshark-9d0e4f6fdb2ed940b625a8b32707027e6f021a95.tar.gz |
don't add nonprinting \000 characters to tftp option strings
Change-Id: I81e43fac5176fdd0805001636991efb7f588a3c0
Reviewed-on: https://code.wireshark.org/review/3252
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Martin Kaiser <wireshark@kaiser.cx>
Diffstat (limited to 'epan/dissectors/packet-tftp.c')
-rw-r--r-- | epan/dissectors/packet-tftp.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/epan/dissectors/packet-tftp.c b/epan/dissectors/packet-tftp.c index 7bed29f0a4..3c56b5ac94 100644 --- a/epan/dissectors/packet-tftp.c +++ b/epan/dissectors/packet-tftp.c @@ -141,11 +141,15 @@ tftp_dissect_options(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *opt_tree; while (tvb_offset_exists(tvb, offset)) { - option_len = tvb_strsize(tvb, offset); /* length of option */ + /* option_len and value_len include the trailing 0 byte */ + option_len = tvb_strsize(tvb, offset); value_offset = offset + option_len; - value_len = tvb_strsize(tvb, value_offset); /* length of value */ - optionname = tvb_format_text(tvb, offset, option_len); - optionvalue = tvb_format_text(tvb, value_offset, value_len); + value_len = tvb_strsize(tvb, value_offset); + /* use xxx_len-1 to exclude the trailing 0 byte, it would be + displayed as nonprinting character + tvb_format_text() creates a temporary 0-terminated buffer */ + optionname = tvb_format_text(tvb, offset, option_len-1); + optionvalue = tvb_format_text(tvb, value_offset, value_len-1); opt_tree = proto_tree_add_subtree_format(tree, tvb, offset, option_len+value_len, ett_tftp_option, NULL, "Option: %s = %s", optionname, optionvalue); |