]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Correctly dissect LockingAndX requests - there's a flag bit that
authorguy <guy>
Tue, 28 Dec 2004 20:38:27 +0000 (20:38 +0000)
committerguy <guy>
Tue, 28 Dec 2004 20:38:27 +0000 (20:38 +0000)
indicates whether the offsets and lengths are 32 bit or 64 bit.

print-smb.c
smbutil.c

index cabe0a2ba82f230639884c7546269bbb69695f49..95bd8d3b3e9333dca0463369feca5b0ba2790b55 100644 (file)
@@ -12,7 +12,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.35 2004-12-28 11:18:29 guy Exp $";
+     "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.36 2004-12-28 20:38:27 guy Exp $";
 #endif
 
 #include <tcpdump-stdinc.h>
@@ -469,6 +469,45 @@ trunc:
     return;
 }
 
+static void
+print_lockingandx(const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
+{
+    u_int wct, bcc;
+    const u_char *maxwords;
+    const char *f1 = NULL, *f2 = NULL;
+
+    TCHECK(words[0]);
+    wct = words[0];
+    if (request) {
+       f1 = "Com2=[w]\nOff2=[d]\nHandle=[d]\nLockType=[w]\nTimeOut=[D]\nUnlockCount=[d]\nLockCount=[d]\n";
+       TCHECK(words[7]);
+       if (words[7] & 0x10)
+           f2 = "*Process=[d]\n[P2]Offset=[M]\nLength=[M]\n";
+       else
+           f2 = "*Process=[d]\nOffset=[D]\nLength=[D]\n";
+    } else {
+       f1 = "Com2=[w]\nOff2=[d]\n";
+    }
+
+    maxwords = SMBMIN(words + 1 + wct * 2, maxbuf);
+    if (wct)
+       smb_fdata(words + 1, f1, maxwords);
+
+    TCHECK2(*data, 2);
+    bcc = EXTRACT_LE_16BITS(data);
+    printf("smb_bcc=%u\n", bcc);
+    if (bcc > 0) {
+       if (f2)
+           smb_fdata(data + 2, f2, SMBMIN(data + 2 + EXTRACT_LE_16BITS(data), maxbuf));
+       else
+           print_data(data + 2, SMBMIN(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
+    }
+    return;
+trunc:
+    printf("[|SMB]");
+    return;
+}
+
 
 static struct smbfns smb_fns[] = {
     { -1, "SMBunknown", 0, DEFDESCRIPT },
@@ -657,11 +696,6 @@ static struct smbfns smb_fns[] = {
          "Com2=[w]\nOff2=[d]\nCount=[d]\nRemaining=[d]\nRes=[W]\n",
          NULL, NULL } },
 
-    { SMBlockingX, "SMBlockingX", FLG_CHAIN,
-       { "Com2=[w]\nOff2=[d]\nHandle=[d]\nLockType=[w]\nTimeOut=[D]\nUnlockCount=[d]\nLockCount=[d]\n",
-         "*Process=[d]\nOffset=[D]\nLength=[D]\n",
-         "Com2=[w]\nOff2=[d]\n", NULL, NULL } },
-
     { SMBffirst, "SMBffirst", 0,
        { "Count=[d]\nAttrib=[A]\n",
          "Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\n",
@@ -718,6 +752,9 @@ static struct smbfns smb_fns[] = {
        { "Com2=[w]\nOff2=[d]\nFlags=[w]\nPassLen=[d]\nPasswd&Path&Device=\n",
          NULL, "Com2=[w]\nOff2=[d]\n", "ServiceType=[S]\n", NULL } },
 
+    { SMBlockingX, "SMBlockingX", FLG_CHAIN,
+       { NULL, NULL, NULL, NULL, print_lockingandx } },
+
     { SMBtrans2, "SMBtrans2", 0, { NULL, NULL, NULL, NULL, print_trans2 } },
 
     { SMBtranss2, "SMBtranss2", 0, DEFDESCRIPT },
index 80b7208aea16e6e9717980f2af3fd04479860ada..cb4c8b53bb6c022e3d0f9da3f4babef67a05db06 100644 (file)
--- a/smbutil.c
+++ b/smbutil.c
@@ -12,7 +12,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.30 2004-12-28 03:34:08 guy Exp $";
+     "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.31 2004-12-28 20:38:27 guy Exp $";
 #endif
 
 #include <tcpdump-stdinc.h>
@@ -464,6 +464,22 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf)
            fmt++;
            break;
          }
+       case 'M':
+         {
+           /* Weird mixed-endian length values in 64-bit locks */
+           u_int32_t x1, x2;
+           u_int64_t x;
+           TCHECK2(buf[0], 8);
+           x1 = reverse ? EXTRACT_32BITS(buf) :
+                          EXTRACT_LE_32BITS(buf);
+           x2 = reverse ? EXTRACT_32BITS(buf + 4) :
+                          EXTRACT_LE_32BITS(buf + 4);
+           x = (((u_int64_t)x1) << 32) | x2;
+           printf("%" PRIu64 " (0x%" PRIx64 ")", x, x);
+           buf += 8;
+           fmt++;
+           break;
+         }
        case 'B':
          {
            unsigned int x;