mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
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 a51288aabb, 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 <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14476
This commit is contained in:
+1
-1
@@ -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) {
|
||||
|
||||
@@ -4590,7 +4590,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
|
||||
B_FALSE, destsnap) == 0) {
|
||||
*strchr(destsnap, '@') = '\0';
|
||||
(void) strlcat(destsnap, suffix,
|
||||
sizeof (destsnap) - strlen(destsnap));
|
||||
sizeof (destsnap));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -4626,7 +4626,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
|
||||
B_FALSE, destsnap) == 0) {
|
||||
*strchr(destsnap, '@') = '\0';
|
||||
(void) strlcat(destsnap, snap,
|
||||
sizeof (destsnap) - strlen(destsnap));
|
||||
sizeof (destsnap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user