NFS: a couple off by ones
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 16 Dec 2014 23:52:26 +0000 (02:52 +0300)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Sat, 31 Jan 2015 01:43:30 +0000 (20:43 -0500)
These tests are off by one because if len == sizeof(nfs_export_path)
then we have truncated the name.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/nfsroot.c

index cd3c910d2d129ee687d197da97b00c9c0cb3cc13..9bc9f04fb7f699bfa9d93ef076fc2c26f12cb065 100644 (file)
@@ -261,11 +261,11 @@ static int __init root_nfs_data(char *cmdline)
         */
        len = snprintf(nfs_export_path, sizeof(nfs_export_path),
                                tmp, utsname()->nodename);
-       if (len > (int)sizeof(nfs_export_path))
+       if (len >= (int)sizeof(nfs_export_path))
                goto out_devnametoolong;
        len = snprintf(nfs_root_device, sizeof(nfs_root_device),
                                "%pI4:%s", &servaddr, nfs_export_path);
-       if (len > (int)sizeof(nfs_root_device))
+       if (len >= (int)sizeof(nfs_root_device))
                goto out_devnametoolong;
 
        retval = 0;