From: Dan Carpenter Date: Tue, 16 Dec 2014 23:52:26 +0000 (+0300) Subject: NFS: a couple off by ones X-Git-Tag: v4.0-rc1~119^2~29 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=c7c545d4a34872f4a3d710e22f21fb61f7258706;p=karo-tx-linux.git NFS: a couple off by ones These tests are off by one because if len == sizeof(nfs_export_path) then we have truncated the name. Signed-off-by: Dan Carpenter Signed-off-by: Trond Myklebust --- diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c index cd3c910d2d12..9bc9f04fb7f6 100644 --- a/fs/nfs/nfsroot.c +++ b/fs/nfs/nfsroot.c @@ -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;