diff options
author | Guy Harris <guy@alum.mit.edu> | 2002-04-29 00:33:30 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2002-04-29 00:33:30 +0000 |
commit | 32567ff10f9cd86b88d42de8d80845a926843813 (patch) | |
tree | 674f396c12b76252c2aab8779d5a56b50d0e9380 | |
parent | fd629d84a8e4cff5759c9913667442982d2f6f2d (diff) |
Use "proto_tree_add_item()" to add the URI string to the protocol tree,
rather than extracting a string and adding that explicitly (which runs
the risk of leaking memory if the "tvb_get_ptr()" throws an exception).
Use "tvb_format_text()" when adding the string to the Info column, so
that non-printable characters are displayed as escapes.
svn path=/trunk/; revision=5283
-rw-r--r-- | packet-wsp.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/packet-wsp.c b/packet-wsp.c index 9698dc09ed..b627c27a66 100644 --- a/packet-wsp.c +++ b/packet-wsp.c @@ -2,7 +2,7 @@ * * Routines to dissect WSP component of WAP traffic. * - * $Id: packet-wsp.c,v 1.55 2002/04/02 20:16:19 guy Exp $ + * $Id: packet-wsp.c,v 1.56 2002/04/29 00:33:30 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1504,7 +1504,6 @@ static void add_uri (proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, guint URILenOffset, guint URIOffset) { proto_item *ti; - char *newBuffer; guint count = 0; guint uriLen = tvb_get_guintvar (tvb, URILenOffset, &count); @@ -1512,16 +1511,12 @@ add_uri (proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, guint URILenOffset if (tree) ti = proto_tree_add_uint (tree, hf_wsp_header_uri_len,tvb,URILenOffset,count,uriLen); - newBuffer = g_malloc (uriLen+2); - newBuffer[0] = ' '; /* This is for COL_INFO */ - strncpy (newBuffer+1, tvb_get_ptr (tvb, URIOffset, uriLen), uriLen); - newBuffer[uriLen+1] = 0; if (tree) - ti = proto_tree_add_string (tree, hf_wsp_header_uri,tvb,URIOffset,uriLen,newBuffer+1); + ti = proto_tree_add_item (tree, hf_wsp_header_uri,tvb,URIOffset,uriLen,bo_little_endian); if (check_col(pinfo->cinfo, COL_INFO)) { - col_append_str(pinfo->cinfo, COL_INFO, newBuffer); - }; - g_free (newBuffer); + col_append_fstr(pinfo->cinfo, COL_INFO, " %s", + tvb_format_text (tvb, URIOffset, uriLen)); + } } static void |