diff options
author | Nathan Neulinger <nneul@umr.edu> | 2002-02-03 16:54:49 +0000 |
---|---|---|
committer | Nathan Neulinger <nneul@umr.edu> | 2002-02-03 16:54:49 +0000 |
commit | ce288efd39fb0f8b4351c2180775f8dd8629fb7c (patch) | |
tree | 07e2510e53fff883192a3629464b69df96250622 /packet-afs-macros.h | |
parent | 5b0fe2e2ef5dde3cc432c451ee8262a49e825abf (diff) | |
download | wireshark-ce288efd39fb0f8b4351c2180775f8dd8629fb7c.tar.gz wireshark-ce288efd39fb0f8b4351c2180775f8dd8629fb7c.tar.bz2 wireshark-ce288efd39fb0f8b4351c2180775f8dd8629fb7c.zip |
Fix string parsing from rx packets. Previously was calculating the next
offset incorrectly, which resulted in the rest of the packet being shifted
by a few bytes, and therefore all garbage.
svn path=/trunk/; revision=4689
Diffstat (limited to 'packet-afs-macros.h')
-rw-r--r-- | packet-afs-macros.h | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/packet-afs-macros.h b/packet-afs-macros.h index 887900b1d6..0822187f00 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.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> @@ -425,22 +425,18 @@ /* 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) */ |