NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: PR lib/59540: strlcpy(3) has an off-by-one in the manual page
> Date: Sun, 04 Jan 2026 15:37:07 +0000
> From: Roland Illig <rillig%NetBSD.org@localhost>
>
> What about "dst + strlen(src) + 1" instead of the brackets notation?
> That would keep the "+ 1" to emphasize the terminating null byte.
No, dst[strlen(src) + 1] and *(dst + strlen(src) + 1) are the same and
both wrong -- while it's true that bytes _past_ that point are left
uninitialized, the byte _at_ that point is also left uninitialized.
The original report is exactly correct and should be applied verbatim
to fix the off-by-one-error I created when I rewrote this prose
earlier this year in an attempt to make it clearer exactly which bytes
get read and written.
Home |
Main Index |
Thread Index |
Old Index