summaryrefslogtreecommitdiff
path: root/print-token.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2010-02-21 00:27:00 -0800
committerGuy Harris <guy@alum.mit.edu>2010-02-21 00:27:00 -0800
commite8b523758959c1854689d71c7a4686c631e5501c (patch)
tree67d50632c8f8f0410d2a8d227a78709a7aca1ca2 /print-token.c
parentb00042a8ae3656f01e022bf6df1eb761e6323d3d (diff)
downloadtcpdump-e8b523758959c1854689d71c7a4686c631e5501c.tar.gz
Don't directly fetch multi-byte integers from packets.
Use the EXTRACT_ macros to extract multi-byte integral values from packets, rather than just dereferencing pointers into the packet; there is no guarantee that the packet data will be aligned on the right boundary, and there is no guarantee that, if they're not, a direct access will work correctly.
Diffstat (limited to 'print-token.c')
-rw-r--r--print-token.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/print-token.c b/print-token.c
index 04defa99..6a1b95da 100644
--- a/print-token.c
+++ b/print-token.c
@@ -39,6 +39,7 @@ static const char rcsid[] _U_ =
#include <string.h>
#include "interface.h"
+#include "extract.h"
#include "addrtoname.h"
#include "ethertype.h"
@@ -135,10 +136,10 @@ token_print(const u_char *p, u_int length, u_int caplen)
printf(" [%d:%d]", RING_NUMBER(trp, seg),
BRIDGE_NUMBER(trp, seg));
} else {
- printf("rt = %x", ntohs(trp->token_rcf));
+ printf("rt = %x", EXTRACT_16BITS(&trp->token_rcf));
for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
- printf(":%x", ntohs(trp->token_rseg[seg]));
+ printf(":%x", EXTRACT_16BITS(&trp->token_rseg[seg]));
}
printf(" (%s) ", largest_frame[LARGEST_FRAME(trp)]);
} else {