HomeFreeBSD

Give strlcat() full buffer lengths rather than smaller buffer lengths

Description

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

Details

Provenance
Richard Yao <richard.yao@alumni.stonybrook.edu>Authored on Feb 14 2023, 7:03 PM
GitHub <noreply@github.com>Committed on Feb 14 2023, 7:03 PM
Parents
rGcfd57573ffea: quick fix for lingering snapdir unmount problems
Branches
Unknown
Tags
Unknown

Event Timeline

GitHub <noreply@github.com> committed rGab672133a9bd: Give strlcat() full buffer lengths rather than smaller buffer lengths (authored by Richard Yao <richard.yao@alumni.stonybrook.edu>).Feb 14 2023, 7:03 PM