]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Always check for "smb_fdata()" returning null - for example, check it on
authorguy <guy>
Thu, 5 May 2005 22:30:03 +0000 (22:30 +0000)
committerguy <guy>
Thu, 5 May 2005 22:30:03 +0000 (22:30 +0000)
every iteration of a loop.

print-smb.c

index 73b8575fd397fb228b27c16feb851aa3fc81a20f..c3cc9b4e50763830a5a4d44360ff139a304d803f 100644 (file)
@@ -12,7 +12,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.41 2004-12-30 03:36:51 guy Exp $";
+     "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.42 2005-05-05 22:30:03 guy Exp $";
 #endif
 
 #include <tcpdump-stdinc.h>
@@ -1141,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) {
@@ -1180,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> ");