From: Guy Harris Date: Wed, 5 Oct 2016 19:21:28 +0000 (-0700) Subject: Before fetching the flags2 field, make sure we have it. X-Git-Tag: tcpdump-4.9.0-bp~45 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/97d372ef7040c30c90faca545e697af1af9b1b39 Before fetching the flags2 field, make sure we have it. Also, don't fetch it until we need it, so we can do a little more dissection before reporting a truncated packet. --- diff --git a/print-smb.c b/print-smb.c index dd0f1045..af86cddb 100644 --- a/print-smb.c +++ b/print-smb.c @@ -806,9 +806,6 @@ print_smb(netdissect_options *ndo, ND_TCHECK(buf[9]); request = (buf[9] & 0x80) ? 0 : 1; - flags2 = EXTRACT_LE_16BITS(&buf[10]); - unicodestr = flags2 & 0x8000; - nterrcodes = flags2 & 0x4000; startbuf = buf; command = buf[4]; @@ -823,6 +820,11 @@ print_smb(netdissect_options *ndo, if (ndo->ndo_vflag < 2) return; + ND_TCHECK_16BITS(&buf[10]); + flags2 = EXTRACT_LE_16BITS(&buf[10]); + unicodestr = flags2 & 0x8000; + nterrcodes = flags2 & 0x4000; + /* print out the header */ smb_fdata(ndo, buf, fmt_smbheader, buf + 33, unicodestr);