]> git.proxmox.com Git - mirror_zfs.git/commit
Give strlcat() full buffer lengths rather than smaller buffer lengths
authorRichard Yao <richard.yao@alumni.stonybrook.edu>
Tue, 14 Feb 2023 19:03:42 +0000 (14:03 -0500)
committerGitHub <noreply@github.com>
Tue, 14 Feb 2023 19:03:42 +0000 (11:03 -0800)
commitab672133a9bde75d20afd59d8db1405c7300a557
tree3ed973983790b6a8e87451da9fed4a923f88c281
parentcfd57573ffea911f464aeaf7ba415daf32fe0bd5
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 <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14476
lib/libshare/nfs.c
lib/libzfs/libzfs_sendrecv.c
module/zfs/dmu_send.c