diff options
author | Guy Harris <guy@alum.mit.edu> | 2002-06-07 11:27:54 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2002-06-07 11:27:54 +0000 |
commit | 76834efbb228d9a021b8472eb12bb81182863b78 (patch) | |
tree | 7ac5e86cc5a8af3f162e307ded7756a6a1e741c6 /packet-socks.c | |
parent | 1eadf370cdbc0474ff34e5ab66bebdd050641fcd (diff) | |
download | wireshark-76834efbb228d9a021b8472eb12bb81182863b78.tar.gz wireshark-76834efbb228d9a021b8472eb12bb81182863b78.tar.bz2 wireshark-76834efbb228d9a021b8472eb12bb81182863b78.zip |
Use "tvb_memcpy()" rather than "strncpy()" with a "tvb_get_ptr()"
argument to copy a counted string, and use "tvb_strsize()" rather tan
"strlen()" with a "tvb_get_ptr()" argument to get the length of a
null-terminated string, so that we throw an exception if we go past the
end of the tvbuff, rather than processing bytes past the end.
svn path=/trunk/; revision=5649
Diffstat (limited to 'packet-socks.c')
-rw-r--r-- | packet-socks.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/packet-socks.c b/packet-socks.c index fa60f16ad8..a12f229b31 100644 --- a/packet-socks.c +++ b/packet-socks.c @@ -2,7 +2,7 @@ * Routines for socks versions 4 &5 packet dissection * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com> * - * $Id: packet-socks.c,v 1.38 2002/04/14 23:04:04 guy Exp $ + * $Id: packet-socks.c,v 1.39 2002/06/07 11:27:54 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -263,11 +263,10 @@ static int display_string(tvbuff_t *tvb, int offset, proto_tree *name_tree; proto_item *ti; - char temp[ 256]; int length = tvb_get_guint8(tvb, offset); - strncpy( temp, tvb_get_ptr(tvb, offset+1, -1), length); + tvb_memcpy(tvb, (guint8 *)temp, offset+1, length); temp[ length ] = 0; ti = proto_tree_add_text(tree, tvb, offset, length + 1, @@ -276,7 +275,7 @@ static int display_string(tvbuff_t *tvb, int offset, name_tree = proto_item_add_subtree(ti, ett_socks_name); - proto_tree_add_text( name_tree, tvb, offset, 1, "Length: %d", length); + proto_tree_add_text( name_tree, tvb, offset, 1, "Length: %u", length); ++offset; @@ -510,7 +509,7 @@ display_socks_v4(tvbuff_t *tvb, int offset, packet_info *pinfo, if ( tvb_offset_exists(tvb, offset)) { /* display user name */ proto_tree_add_string( tree, hf_user_name, tvb, offset, - strlen( tvb_get_ptr(tvb, offset, -1)) + 1, + tvb_strsize(tvb, offset), tvb_get_ptr(tvb, offset, -1)); } @@ -543,7 +542,7 @@ display_socks_v4(tvbuff_t *tvb, int offset, packet_info *pinfo, /* Should perhaps do TCP reassembly as well */ if ( tvb_offset_exists(tvb, offset)) { proto_tree_add_text( tree, tvb, offset, - strlen( tvb_get_ptr(tvb, offset, -1)), + tvb_strsize(tvb, offset), "User Name: %s", tvb_get_ptr(tvb, offset, -1)); } } @@ -697,7 +696,7 @@ state_machine_v4( socks_hash_entry_t *hash_info, tvbuff_t *tvb, hash_info->state = V4UserNameWait; - hash_info->connect_offset += strlen( tvb_get_ptr(tvb, offset, -1)) + 1; + hash_info->connect_offset += tvb_strsize(tvb, offset) + 1; if ( !hash_info->dst_addr){ /* if no dest address */ /* if more data */ |