]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Before fetching the flags2 field, make sure we have it.
authorGuy Harris <[email protected]>
Wed, 5 Oct 2016 19:21:28 +0000 (12:21 -0700)
committerFrancois-Xavier Le Bail <[email protected]>
Wed, 18 Jan 2017 08:16:40 +0000 (09:16 +0100)
Also, don't fetch it until we need it, so we can do a little more
dissection before reporting a truncated packet.

print-smb.c

index dd0f10453e5c168b7a5afa38c4406949c3d72f60..af86cddbafd78ff21b9d2c1ed0a6f91ebcbcbb22 100644 (file)
@@ -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);