Message ID | 7f97bb62c4e8137c5d7f7a7a30789440a5102b3f.1698183837.git.christophe.jaillet@wanadoo.fr (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | NFS: Fix an off by one in root_nfs_cat() | expand |
On 24 Oct 2023, at 17:47, Christophe JAILLET wrote: > The intent is to check if the '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> Minor typo in the body: >+ should be >=, otherwise looks right. Reviewed-by: Benjamin Coddington <bcodding@redhat.com> Ben
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; }
The intent is to check if the '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> --- fs/nfs/nfsroot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)