aboutsummaryrefslogtreecommitdiffstats
path: root/packet-afs-macros.h
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-10-11 21:58:25 +0000
committerGuy Harris <guy@alum.mit.edu>2002-10-11 21:58:25 +0000
commitf58cd0bd5cc68668a18feb5e7aa16594fe924873 (patch)
tree0a84899a0d16fef58940a585b7684b64b06f8e3f /packet-afs-macros.h
parente4b32038a774328895afdf517bb7202c8ef34462 (diff)
Fetch the pointer to a string before allocating memory for the string,
so that if the string length is bogus and large, we'll throw an exception in "tvb_get_ptr()" rather than crashing when we fail to allocate the memory. svn path=/trunk/; revision=6413
Diffstat (limited to 'packet-afs-macros.h')
-rw-r--r--packet-afs-macros.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/packet-afs-macros.h b/packet-afs-macros.h
index 0dd2ebfe53..1807322ff6 100644
--- a/packet-afs-macros.h
+++ b/packet-afs-macros.h
@@ -8,7 +8,7 @@
* Portions based on information/specs retrieved from the OpenAFS sources at
* www.openafs.org, Copyright IBM.
*
- * $Id: packet-afs-macros.h,v 1.20 2002/09/30 02:19:37 gerald Exp $
+ * $Id: packet-afs-macros.h,v 1.21 2002/10/11 21:58:25 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -112,11 +112,13 @@
#define OUT_RXString(field) \
{ int i,len; \
char *tmp; \
+ const char *p; \
i = tvb_get_ntohl(tvb, offset); \
offset += 4; \
+ p = tvb_get_ptr(tvb,offset,i); \
len = ((i+4-1)/4)*4; \
tmp = g_malloc(i+1); \
- memcpy(tmp, tvb_get_ptr(tvb,offset,i), i); \
+ memcpy(tmp, p, i); \
tmp[i] = '\0'; \
proto_tree_add_string(tree, field, tvb, offset-4, len+4, \
(void *)tmp); \