]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-smb.c
Add an "fn_printzp()" routine for printing null-padded strings (strings
[tcpdump] / print-smb.c
index 573e7c80d7bc7febe792170c68b5d85b793cb35f..7d64c61efe113888841959c98b4e30fa0a805f4e 100644 (file)
@@ -12,7 +12,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.40 2004-12-29 03:10:24 guy Exp $";
+     "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.41.2.1 2005-05-05 22:30:40 guy Exp $";
 #endif
 
 #include <tcpdump-stdinc.h>
@@ -794,7 +794,10 @@ static struct smbfns smb_fns[] = {
 static void
 print_smb(const u_char *buf, const u_char *maxbuf)
 {
+    u_int16_t flags2;
+    int nterrcodes;
     int command;
+    u_int32_t nterror;
     const u_char *words, *maxwords, *data;
     struct smbfns *fn;
     const char *fmt_smbheader =
@@ -803,7 +806,9 @@ print_smb(const u_char *buf, const u_char *maxbuf)
 
     TCHECK(buf[9]);
     request = (buf[9] & 0x80) ? 0 : 1;
-    unicodestr = EXTRACT_LE_16BITS(&buf[10]) & 0x8000;
+    flags2 = EXTRACT_LE_16BITS(&buf[10]);
+    unicodestr = flags2 & 0x8000;
+    nterrcodes = flags2 & 0x4000;
     startbuf = buf;
 
     command = buf[4];
@@ -821,8 +826,14 @@ print_smb(const u_char *buf, const u_char *maxbuf)
     /* print out the header */
     smb_fdata(buf, fmt_smbheader, buf + 33, unicodestr);
 
-    if (buf[5])
-       printf("SMBError = %s\n", smb_errstr(buf[5], EXTRACT_LE_16BITS(&buf[7])));
+    if (nterrcodes) {
+       nterror = EXTRACT_LE_32BITS(&buf[5]);
+       if (nterror)
+           printf("NTError = %s\n", nt_errstr(nterror));
+    } else {
+       if (buf[5])
+           printf("SMBError = %s\n", smb_errstr(buf[5], EXTRACT_LE_16BITS(&buf[7])));
+    }
 
     smboffset = 32;
 
@@ -1130,12 +1141,13 @@ nbt_udp137_print(const u_char *data, int length)
 
     if (qdcount) {
        printf("QuestionRecords:\n");
-       for (i = 0; i < qdcount; i++)
+       for (i = 0; i < qdcount; i++) {
            p = smb_fdata(p,
                "|Name=[n1]\nQuestionType=[rw]\nQuestionClass=[rw]\n#",
                maxbuf, 0);
-       if (p == NULL)
-           goto out;
+           if (p == NULL)
+               goto out;
+       }
     }
 
     if (total) {
@@ -1169,6 +1181,8 @@ nbt_udp137_print(const u_char *data, int length)
                        goto out;
                    while (numnames--) {
                        p = smb_fdata(p, "Name=[n2]\t#", maxbuf, 0);
+                       if (p == NULL)
+                           goto out;
                        TCHECK(*p);
                        if (p[0] & 0x80)
                            printf("<GROUP> ");