summaryrefslogtreecommitdiff
path: root/usr.sbin/tcpdump/print-gtp.c
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2011-09-18 10:24:17 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2011-09-18 10:24:17 +0000
commita7ddd4c92498f0e8d565f15959dc99a464ec51a1 (patch)
tree4d35d99e23d7a7fa0b3da05d45c35b3eece547cd /usr.sbin/tcpdump/print-gtp.c
parenta0b3c4afc8cae8961a7c7c1555a57a1a1866b716 (diff)
Avoid potential 64-bit unaligned access on strict alignment architectures.
Spotted by and ok naddy@
Diffstat (limited to 'usr.sbin/tcpdump/print-gtp.c')
-rw-r--r--usr.sbin/tcpdump/print-gtp.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.sbin/tcpdump/print-gtp.c b/usr.sbin/tcpdump/print-gtp.c
index d3c34b77296..e13e80314e9 100644
--- a/usr.sbin/tcpdump/print-gtp.c
+++ b/usr.sbin/tcpdump/print-gtp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print-gtp.c,v 1.3 2010/08/19 15:26:38 jsing Exp $ */
+/* $OpenBSD: print-gtp.c,v 1.4 2011/09/18 10:24:16 jsing Exp $ */
/*
* Copyright (c) 2009, 2010 Joel Sing <jsing@openbsd.org>
*
@@ -487,6 +487,7 @@ gtp_v0_print(const u_char *cp, u_int length, u_short sport, u_short dport)
{
struct gtp_v0_hdr *gh = (struct gtp_v0_hdr *)cp;
int len, version;
+ u_int64_t tid;
gtp_proto = GTP_V0_PROTO;
@@ -502,9 +503,10 @@ gtp_v0_print(const u_char *cp, u_int length, u_short sport, u_short dport)
TCHECK(*gh);
cp += sizeof(struct gtp_v0_hdr);
len = ntohs(gh->length);
+ bcopy(&gh->tid, &tid, sizeof(tid));
printf(" GTPv0 (len %u, seqno %u, flow %u, N-PDU %u, tid 0x%llx) ",
ntohs(gh->length), ntohs(gh->seqno), ntohs(gh->flow),
- ntohs(gh->npduno), betoh64(gh->tid));
+ ntohs(gh->npduno), betoh64(tid));
/* Decode GTP message. */
printf("%s", tok2str(gtp_v0_msgtype, "Message Type %u", gh->msgtype));