From: Guy Harris Date: Tue, 25 Aug 2015 01:14:55 +0000 (-0700) Subject: Don't assume the ONC RPC header is nicely aligned. X-Git-Tag: tcpdump-4.8.0~189 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/5fc3681a13029958e5515213e13da1f19f338a7e?hp=2d82e8fee78b4c2eafdffac97d5c11a3b58952ca Don't assume the ONC RPC header is nicely aligned. Use UNALIGNED_MEMCPY() to extract the XID from it; otherwise, this might crash on machines that require strict alignment (e.g., SPARC machines). Fixes GitHub issue #478. --- diff --git a/print-nfs.c b/print-nfs.c index 50334d10..ac51f7ee 100644 --- a/print-nfs.c +++ b/print-nfs.c @@ -932,13 +932,14 @@ xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, uint32_t *proc, { int i; struct xid_map_entry *xmep; - uint32_t xid = rp->rm_xid; + uint32_t xid; const struct ip *ip = (const struct ip *)bp; #ifdef INET6 const struct ip6_hdr *ip6 = (const struct ip6_hdr *)bp; #endif int cmp; + UNALIGNED_MEMCPY(&xid, &rp->rm_xid, sizeof(xmep->xid)); /* Start searching from where we last left off */ i = xid_map_hint; do {