diff options
| author | Christophe JAILLET <christophe.jaillet@wanadoo.fr> | 2024-02-18 22:16:53 +0100 |
|---|---|---|
| committer | Sasha Levin <sashal@kernel.org> | 2024-03-26 18:22:24 -0400 |
| commit | afcbba70bf553f00c7703627378e28debcbcf815 (patch) | |
| tree | 92528f142814ab79070152b0dfb6ff18450cc882 | |
| parent | bcc3ec2bdbdac2f11b1f8643bf3c5d4368d18a85 (diff) | |
| download | linux-afcbba70bf553f00c7703627378e28debcbcf815.tar.gz linux-afcbba70bf553f00c7703627378e28debcbcf815.tar.bz2 linux-afcbba70bf553f00c7703627378e28debcbcf815.zip | |
NFS: Fix an off by one in root_nfs_cat()
[ Upstream commit 698ad1a538da0b6bf969cfee630b4e3a026afb87 ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
| -rw-r--r-- | fs/nfs/nfsroot.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c index effaa4247b91..c0f2e1751c33 100644 --- a/fs/nfs/nfsroot.c +++ b/fs/nfs/nfsroot.c @@ -169,10 +169,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; } |
