Fix string parsing from rx packets. Previously was calculating the next
authornneul <nneul@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 3 Feb 2002 16:54:49 +0000 (16:54 +0000)
committernneul <nneul@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 3 Feb 2002 16:54:49 +0000 (16:54 +0000)
offset incorrectly, which resulted in the rest of the packet being shifted
by a few bytes, and therefore all garbage.

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

packet-afs-macros.h

index 887900b1d661e1b0361259f5daefddfafb7e1c22..0822187f00c79373e6fc6b3ec875a38ad6702e6a 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.13 2002/01/18 21:30:05 nneul Exp $
+ * $Id: packet-afs-macros.h,v 1.14 2002/02/03 16:54:49 nneul Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
 /* Output a rx style string, up to a maximum length first 
    4 bytes - length, then char data */
 #define OUT_STRING(field) \
-       {       int i; \
+       {       int i,len; \
                i = tvb_get_ntohl(tvb, offset); \
                offset += 4; \
-               if ( i > 0 ) { \
-                       char *tmp; \
-                       tmp = g_malloc(i+1); \
-                       memcpy(tmp, tvb_get_ptr(tvb,offset,i), i); \
-                       tmp[i] = '\0'; \
-                       proto_tree_add_string(tree, field, tvb, offset-4, i+4, \
-                       (void *)tmp); \
-                       g_free(tmp); \
-               } else { \
-                       proto_tree_add_string(tree, field, tvb, offset-4, 4, \
-                       ""); \
-               } \
-               offset += i; \
+               len = ((i+4-1)/4)*4; \
+               char *tmp; \
+               tmp = g_malloc(i+1); \
+               memcpy(tmp, tvb_get_ptr(tvb,offset,i), i); \
+               tmp[i] = '\0'; \
+               proto_tree_add_string(tree, field, tvb, offset-4, len+4, \
+               (void *)tmp); \
+               g_free(tmp); \
+               offset += len; \
        }
 
 /* Output a fixed length vectorized string (each char is a 32 bit int) */