summaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfsroot.c
diff options
context:
space:
mode:
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>2024-02-18 22:16:53 +0100
committerTrond Myklebust <trond.myklebust@hammerspace.com>2024-03-09 09:14:51 -0500
commit698ad1a538da0b6bf969cfee630b4e3a026afb87 (patch)
treeed2c010820266d04cda083361d58657f1013e1f0 /fs/nfs/nfsroot.c
parent1548036ef1204df65ca5a16e8b199c858cb80075 (diff)
downloadlinux-698ad1a538da0b6bf969cfee630b4e3a026afb87.tar.gz
linux-698ad1a538da0b6bf969cfee630b4e3a026afb87.tar.bz2
linux-698ad1a538da0b6bf969cfee630b4e3a026afb87.zip
NFS: Fix an off by one in root_nfs_cat()
The intent is to check if 'dest' is truncated or not. So, >= should be used instead of >, because strlcat() returns the length of 'dest' and 'src' excluding the trailing NULL. Fixes: 56463e50d1fc ("NFS: Use super.c for NFSROOT mount option parsing") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Benjamin Coddington <bcodding@redhat.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Diffstat (limited to 'fs/nfs/nfsroot.c')
-rw-r--r--fs/nfs/nfsroot.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c
index 7600100ba26f..432612d22437 100644
--- a/fs/nfs/nfsroot.c
+++ b/fs/nfs/nfsroot.c
@@ -175,10 +175,10 @@ static int __init root_nfs_cat(char *dest, const char *src,
size_t len = strlen(dest);
if (len && dest[len - 1] != ',')
- if (strlcat(dest, ",", destlen) > destlen)
+ if (strlcat(dest, ",", destlen) >= destlen)
return -1;
- if (strlcat(dest, src, destlen) > destlen)
+ if (strlcat(dest, src, destlen) >= destlen)
return -1;
return 0;
}