Fetch the pointer to a string before allocating memory for the string,
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 11 Oct 2002 21:58:25 +0000 (21:58 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 11 Oct 2002 21:58:25 +0000 (21:58 +0000)
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.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@6413 f5534014-38df-0310-8fa8-9805f1628bb7

packet-afs-macros.h

index 0dd2ebfe53e4bb6caf95a29407f064c503da3d1f..1807322ff6e360994a143bc76f47f9deaa38e0c5 100644 (file)
@@ -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>
 #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); \