]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-smb.c
Fix printing of Linux cooked captures with monitor-mode packets.
[tcpdump] / print-smb.c
index 174fd9afda7af3e8e8d5b9677933ac5f68cc7452..5af01aea06d55eee4a4abce331ebc421cf9b6476 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);
 
@@ -938,7 +940,9 @@ nbt_tcp_print(netdissect_options *ndo,
     if (caplen < 4)
        goto trunc;
     maxbuf = data + caplen;
+    ND_TCHECK_8BITS(data);
     type = data[0];
+    ND_TCHECK_16BITS(data + 2);
     nbt_len = EXTRACT_16BITS(data + 2);
     length -= 4;
     caplen -= 4;
@@ -1165,10 +1169,12 @@ nbt_udp137_print(netdissect_options *ndo,
            p = smb_fdata(ndo, p, "Name=[n1]\n#", maxbuf, 0);
            if (p == NULL)
                goto out;
+           ND_TCHECK_16BITS(p);
            restype = EXTRACT_16BITS(p);
            p = smb_fdata(ndo, p, "ResType=[rw]\nResClass=[rw]\nTTL=[rD]\n", p + 8, 0);
            if (p == NULL)
                goto out;
+           ND_TCHECK_16BITS(p);
            rdlen = EXTRACT_16BITS(p);
            ND_PRINT((ndo, "ResourceLength=%d\nResourceData=\n", rdlen));
            p += 2;
@@ -1310,7 +1316,7 @@ out:
 /*
    print netbeui frames
 */
-struct nbf_strings {
+static struct nbf_strings {
        const char      *name;
        const char      *nonverbose;
        const char      *verbose;