Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Christophe JAILLET and committed by
Trond Myklebust
698ad1a5 1548036e

+2 -2
+2 -2
fs/nfs/nfsroot.c
··· 175 175 size_t len = strlen(dest); 176 176 177 177 if (len && dest[len - 1] != ',') 178 - if (strlcat(dest, ",", destlen) > destlen) 178 + if (strlcat(dest, ",", destlen) >= destlen) 179 179 return -1; 180 180 181 - if (strlcat(dest, src, destlen) > destlen) 181 + if (strlcat(dest, src, destlen) >= destlen) 182 182 return -1; 183 183 return 0; 184 184 }