In print_data(), check each byte to make sure we haven't gone past the
authorguy <guy>
Sun, 15 Jul 2007 19:08:25 +0000 (19:08 +0000)
committerguy <guy>
Sun, 15 Jul 2007 19:08:25 +0000 (19:08 +0000)
end of the captured packet data.

smbutil.c

index 86cbb8dd17769d7eedd9056d988de1555a746660..1e9e7e21e1eab992b7ce678a2f23388fb90efb99 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.2.2 2007-06-15 19:49:15 guy Exp $";
+     "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.36.2.3 2007-07-15 19:08:25 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");
 }