aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libshare
diff options
context:
space:
mode:
authorRichard Yao <[email protected]>2023-02-14 14:03:42 -0500
committerGitHub <[email protected]>2023-02-14 11:03:42 -0800
commitab672133a9bde75d20afd59d8db1405c7300a557 (patch)
tree3ed973983790b6a8e87451da9fed4a923f88c281 /lib/libshare
parentcfd57573ffea911f464aeaf7ba415daf32fe0bd5 (diff)
Give strlcat() full buffer lengths rather than smaller buffer lengths
strlcat() is supposed to be given the length of the destination buffer, including the existing contents. Unfortunately, I had been overzealous when I wrote a51288aabbbc176a8a73a8b3cd56f79607db32cf, since I gave it the length of the destination buffer, minus the existing contents. This likely caused a regression on large strings. On the topic of being overzealous, the use of strlcat() in dmu_send_estimate_fast() was unnecessary because recv_clone_name is a fixed length string. We continue using strlcat() mostly as defensive programming, in case the string length is ever changed, even though it is unnecessary. Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Richard Yao <[email protected]> Closes #14476
Diffstat (limited to 'lib/libshare')
-rw-r--r--lib/libshare/nfs.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libshare/nfs.c b/lib/libshare/nfs.c
index 118ad7ef2..3962c8745 100644
--- a/lib/libshare/nfs.c
+++ b/lib/libshare/nfs.c
@@ -97,7 +97,7 @@ nfs_init_tmpfile(const char *prefix, const char *mdir, struct tmpfile *tmpf)
}
strlcpy(tmpf->name, prefix, sizeof (tmpf->name));
- strlcat(tmpf->name, ".XXXXXXXX", sizeof (tmpf->name) - strlen(prefix));
+ strlcat(tmpf->name, ".XXXXXXXX", sizeof (tmpf->name));
int fd = mkostemp(tmpf->name, O_CLOEXEC);
if (fd == -1) {