[PATCH 1/2] Implement strlcpy and strlcat [BZ #178]
Florian Weimer
fweimer@redhat.com
Thu Apr 13 11:37:12 GMT 2023
* Paul Eggert:
> +The behavior is undefined if @var{to} or @var{from} is a null pointer,
> +or if the destination array's size is both less than @var{size} and
> +less than or equal to the length of the string @var{from}, or if
> +the string @var{from} overlaps the result (that is, if @var{from}
> +overlaps the first @samp{MIN (@var{size}, strlen (@var{from}) + 1)}
> +bytes of the the destination array @var{to}).
This makes it defined to call strlcpy with an incorrect (too small)
destination buffer size as long as the source string is short enough.
Is this really necessary? The fortified implementation checks the
destination buffer size unconditionally (like we do for other
functions), and it does not match this documentation as a result.
Thanks,
Florian
More information about the Libc-alpha
mailing list