summaryrefslogtreecommitdiff
path: root/print-enc.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-enc.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-enc.c')
-rw-r--r--print-enc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/print-enc.c b/print-enc.c
index 0dc48fd7..e98f7f78 100644
--- a/print-enc.c
+++ b/print-enc.c
@@ -35,6 +35,7 @@ static const char rcsid[] _U_ =
#include <pcap.h>
#include "interface.h"
+#include "extract.h"
#include "addrtoname.h"
#include "enc.h"
@@ -67,7 +68,7 @@ enc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
ENC_PRINT_TYPE(flags, M_AUTH, "authentic");
ENC_PRINT_TYPE(flags, M_CONF, "confidential");
/* ENC_PRINT_TYPE(flags, M_TUNNEL, "tunnel"); */
- printf("SPI 0x%08x: ", (u_int32_t)ntohl(hdr->spi));
+ printf("SPI 0x%08x: ", EXTRACT_32BITS(&hdr->spi));
length -= ENC_HDRLEN;
caplen -= ENC_HDRLEN;