This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Implement strlcat [BZ#178]
- From: Zack Weinberg <zackw at panix dot com>
- To: Paul Eggert <eggert at cs dot ucla dot edu>
- Cc: Florian Weimer <fweimer at redhat dot com>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Fri, 4 Dec 2015 09:20:19 -0500
- Subject: Re: [PATCH] Implement strlcat [BZ#178]
- Authentication-results: sourceware.org; auth=none
- References: <56547472 dot 3010302 at redhat dot com> <5654B1FE dot 5020100 at cs dot ucla dot edu> <5654B796 dot 7070302 at redhat dot com> <5656E018 dot 5020608 at cs dot ucla dot edu> <565F211A dot 2030909 at redhat dot com> <56607CD1 dot 3050209 at cs dot ucla dot edu> <CAKCAbMgDMK9wjfNEJYW7e-cN9s5aVhun6V08OXrcOgYKRYF7_g at mail dot gmail dot com> <5660825E dot 9020901 at cs dot ucla dot edu> <CAKCAbMi2zSJRjS=ceg8UvTYY18UrCWysaOFX+OzvKZQfeR9+SA at mail dot gmail dot com> <5660C545 dot 1090805 at cs dot ucla dot edu>
On 12/03/2015 05:42 PM, Paul Eggert wrote:
> On 12/03/2015 10:08 AM, Zack Weinberg wrote:
>> char *my_strdup(char *s)
>
> Sorry, I should have been clearer. I'd like to see real-world
> applications that care about these weird corner cases.
I really do not see this as a weird corner case. I see it as the
expected, natural behavior - if dstsize=0, nothing is written to the
destination, and the return value is unaffected; because nothing is
written to the destination when dstsize=0, it is safe to pass dest=NULL
when dstsize=0.
Again, this is consistent with snprintf, and I think maintaining that
consistency would be a compelling argument even if it wasn't the *BSD
behavior.
> I'm skeptical that such applications exist.
I do not have time to do more than a cursory search, which turns up no
such applications; however, I do not consider "we don't know of any such
applications" an acceptable excuse for deviating from the *BSD behavior.
I reiterate that
>> If we're going to have these functions at all, they need to work
>> _exactly_ as they do on *BSD.
If they don't work _exactly_ as they do on *BSD, people will not stop
using substitute definitions with glibc and there will have been no
point in adding them!
> There is no "_exactly_". The BSDs differ.
I would consider the example you gave (NetBSD not allowing dst=NULL when
dstsize=0) a bug in NetBSD, not to be emulated.
zw