Skip to content

Commit 698ad1a

Browse files
tititiou36Trond Myklebust
authored andcommitted
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: 56463e5 ("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>
1 parent 1548036 commit 698ad1a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/nfs/nfsroot.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@ static int __init root_nfs_cat(char *dest, const char *src,
175175
size_t len = strlen(dest);
176176

177177
if (len && dest[len - 1] != ',')
178-
if (strlcat(dest, ",", destlen) > destlen)
178+
if (strlcat(dest, ",", destlen) >= destlen)
179179
return -1;
180180

181-
if (strlcat(dest, src, destlen) > destlen)
181+
if (strlcat(dest, src, destlen) >= destlen)
182182
return -1;
183183
return 0;
184184
}

0 commit comments

Comments
 (0)