[PATCH] Implement strlcat [BZ#178]
Paul Eggert
eggert@cs.ucla.edu
Tue Nov 24 20:36:00 GMT 2015
On 11/24/2015 11:16 AM, Florian Weimer wrote:
> We don't do that for snprintf, which is very similar, and
> we do not check most snprintf results in glibc.
That's a bad precedent and we should not make things worse by furthering
it. In the places where glibc calls snprintf without checking the return
value, snprintf never silently truncates its output, so the extra size
argument is merely making the code more confusing (and a bit slower) and
glibc should be calling sprintf instead.
The confusion in question doesn't merely affect the human reader. This
is an area where using snprintf makes glibc less reliable, assuming
reasonably modern security technology. If one of these unchecked
snprintf calls were buggy and actually did silently truncate its output,
the bug would be masked by glibc's current use of snprintf, whereas if
the code used sprintf with fortify checking the bug would be caught and
reported.
Thanks for the updated manual patch; I'll take a look at it.
More information about the Libc-alpha
mailing list