[PATCH v3] Implement strlcpy [BZ #178]
Paul Eggert
eggert@cs.ucla.edu
Thu Oct 29 21:53:00 GMT 2015
On 10/29/2015 02:50 PM, Paul Eggert wrote:
> We can pair this with similar phrasing under strlcpy -- something like
> the following perhaps (this wording assumes strlcpy is changed to use
> memmove):"Often @code{strlcpy} is not what you want, because it does
> not null-terminate the destination if the destination's size is
> zero,it can leave junk data behind in the destination, it can do
> useless work when the source is long and the destination short, and it
> may truncate the destination. Although one alternative is
> @code{strncpy}, it is usually better to use dynamic memory allocation
> and functions such as @code{strdup} or @code{asprintf} to construct
> strings."
One more thing: we should add "it requires the source to be
null-terminated even when it is longer than the destination".
More information about the Libc-alpha
mailing list