]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-nfs.c
CI: Add warning exemptions for Sun C (suncc-5.15) on Solaris 10
[tcpdump] / print-nfs.c
index 4378121a0fc3319c833433b9c6e0bccc5e79ff38..b67ec370ed67a7bf4b2082b9c68d0ce61662a44e 100644 (file)
@@ -21,9 +21,7 @@
 
 /* \summary: Network File System (NFS) printer */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include "netdissect-stdinc.h"
 
@@ -434,6 +432,11 @@ parsereq(netdissect_options *ndo,
        if (length < 2 * sizeof(*dp))
                goto trunc;
        len = GET_BE_U_4(dp + 1);
+       if (len > length) {
+               ND_PRINT(" [credentials length %u > %u]", len, length);
+               nd_print_invalid(ndo);
+               return NULL;
+       }
        rounded_len = roundup2(len, 4);
        ND_TCHECK_LEN(dp + 2, rounded_len);
        if (2 * sizeof(*dp) + rounded_len <= length) {
@@ -453,6 +456,11 @@ parsereq(netdissect_options *ndo,
                if (length < 2 * sizeof(*dp))
                        goto trunc;
                len = GET_BE_U_4(dp + 1);
+               if (len > length) {
+                       ND_PRINT(" [verifier length %u > %u]", len, length);
+                       nd_print_invalid(ndo);
+                       return NULL;
+               }
                rounded_len = roundup2(len, 4);
                ND_TCHECK_LEN(dp + 2, rounded_len);
                if (2 * sizeof(*dp) + rounded_len < length) {
@@ -896,15 +904,17 @@ nfs_printfh(netdissect_options *ndo,
                if (spacep)
                        *spacep = '\0';
 
-               ND_PRINT(" fh %s/", temp);
+               ND_PRINT(" fh ");
+               fn_print_str(ndo, (const u_char *)temp);
+               ND_PRINT("/");
        } else {
                ND_PRINT(" fh %u,%u/",
                             fsid.Fsid_dev.Major, fsid.Fsid_dev.Minor);
        }
 
-       if(fsid.Fsid_dev.Minor == 257)
+       if(fsid.Fsid_dev.Minor == UINT_MAX && fsid.Fsid_dev.Major == UINT_MAX)
                /* Print the undecoded handle */
-               ND_PRINT("%s", fsid.Opaque_Handle);
+               fn_print_str(ndo, (const u_char *)fsid.Opaque_Handle);
        else
                ND_PRINT("%u", ino);
 }