aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2001-07-08 19:26:33 +0000
committerGuy Harris <guy@alum.mit.edu>2001-07-08 19:26:33 +0000
commita3137abdeea2f9aa30d4a81da362ee250813d4fc (patch)
tree954d61d91e33437fe85c46234ee6bda3ed7106ff
parentd47dac785e109ea68466577c3080b189b69364b9 (diff)
Use tvbuff-based routines to find the length of single-bit-character-set
strings. svn path=/trunk/; revision=3662
-rw-r--r--packet-smb-common.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/packet-smb-common.c b/packet-smb-common.c
index 05bc8adfda..6c12d57383 100644
--- a/packet-smb-common.c
+++ b/packet-smb-common.c
@@ -2,7 +2,7 @@
* Common routines for smb packet dissection
* Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
*
- * $Id: packet-smb-common.c,v 1.5 2001/07/08 11:32:02 guy Exp $
+ * $Id: packet-smb-common.c,v 1.6 2001/07/08 19:26:33 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -34,12 +34,27 @@ int display_ms_string(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int o
/* display a string from the tree and return the new offset */
- /* XXX - should use tvbuff routines to extract string length */
- str = tvb_get_ptr(tvb, offset, 1);
- len = strlen(str);
+ len = tvb_strnlen(tvb, offset, -1);
+ if (len == -1) {
+ /*
+ * XXX - throw an exception?
+ */
+ len = tvb_length_remaining(tvb, offset);
+ }
+ str = g_malloc(len+1);
+ tvb_memcpy(tvb, (guint8 *)str, offset, len);
+ str[len] = '\0';
- proto_tree_add_string(tree, hf_index, tvb, offset, len, str);
+ proto_tree_add_string(tree, hf_index, tvb, offset, len+1, str);
+ /*
+ * XXX - "proto_tree_add_string()" mallocates a copy; it'd
+ * be nice not to have it copy the string, but just to
+ * make it the value, avoiding both the copy and the free
+ * on the next line.
+ */
+ g_free(str);
+
return offset+len+1;
}