]> The Tcpdump Group git mirrors - tcpdump/blobdiff - smbutil.c
Address Michael's comments.
[tcpdump] / smbutil.c
index ec26f3319d4aaed9b39d91aa03ae8f705375f6f1..5eadb4fdb5645f101a974aa2caea72b930cd2083 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.36 2005-01-29 10:37:02 guy Exp $";
+     "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.39 2007-07-15 19:07:39 guy Exp $";
 #endif
 
 #include <tcpdump-stdinc.h>
@@ -279,6 +279,7 @@ print_data(const unsigned char *buf, int len)
        return;
     printf("[%03X] ", i);
     for (i = 0; i < len; /*nothing*/) {
+        TCHECK(buf[i]);
        printf("%02X ", buf[i] & 0xff);
        i++;
        if (i%8 == 0)
@@ -310,6 +311,11 @@ print_data(const unsigned char *buf, int len)
            print_asc(&buf[i - n], n);
        printf("\n");
     }
+    return;
+
+trunc:
+    printf("\n");
+    printf("WARNING: Short packet. Try increasing the snap length\n");
 }
 
 
@@ -428,7 +434,6 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
 {
     int reverse = 0;
     const char *attrib_fmt = "READONLY|HIDDEN|SYSTEM|VOLUME|DIR|ARCHIVE|";
-    int len;
 
     while (*fmt && buf<maxbuf) {
        switch (*fmt) {
@@ -608,6 +613,8 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
          {
            /*XXX unistr() */
            const char *s;
+           u_int32_t len;
+
            len = 0;
            s = unistr(buf, &len, (*fmt == 'R') ? 0 : unicodestr);
            if (s == NULL)
@@ -621,6 +628,8 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
        case 'Y':       /* like 'Z', but always ASCII */
          {
            const char *s;
+           u_int32_t len;
+
            TCHECK(*buf);
            if (*buf != 4 && *buf != 2) {
                printf("Error! ASCIIZ buffer of type %u", *buf);
@@ -742,6 +751,9 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
                t = interpret_long_date(buf);
                buf += 8;
                break;
+           default:
+               t = 0;
+               break;
            }
            if (t != 0) {
                lt = localtime(&t);
@@ -888,7 +900,7 @@ static const err_code_struct dos_msgs[] = {
  };
 
 /* Server Error Messages */
-err_code_struct server_msgs[] = {
+static const err_code_struct server_msgs[] = {
     { "ERRerror", 1, "Non-specific error code." },
     { "ERRbadpw", 2, "Bad password - name/password pair in a Tree Connect or Session Setup are invalid." },
     { "ERRbadtype", 3, "reserved." },
@@ -925,7 +937,7 @@ err_code_struct server_msgs[] = {
 };
 
 /* Hard Error Messages */
-err_code_struct hard_msgs[] = {
+static const err_code_struct hard_msgs[] = {
     { "ERRnowrite", 19, "Attempt to write on write-protected diskette." },
     { "ERRbadunit", 20, "Unknown unit." },
     { "ERRnotready", 21, "Drive not ready." },