This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Implement strlcat [BZ#178]


On 12/10/2015 08:44 AM, Florian Weimer wrote:
everything points towards the NetBSD
implementation being buggy in this regard

"everything"? Nothing indicates that the NetBSD behavior is a bug; it doesn't cause real applications to break. And the NetBSD behavior can help catch buggy usage, such as "char *buf = malloc (n); strlcpy (buf, src, n - m);" on platforms where NULL points to accessible storage, malloc (0) returns NULL, and n happens to be 0.

The main point of strlcpy+strlcat is to guarantee that the output is always a null-terminated string that fits.This is what programmers understandably expect. This main point is *far* more important than obscure details about weird corner cases that should never happen anyway. The spec should allow an implementation that guarantees the main point, and that terminates the program if the program tries to exploit the corner cases by passing bad pointers or null pointers or unterminated strings or size-zero buffers that prevent the main point from being safely satisfied.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]