[PATCH 3/3] Add _FORTIFY_SOURCE support for inet_ntop

Florian Weimer fweimer@redhat.com
Tue Mar 18 11:53:59 GMT 2025


* Frederic Berat:

> On Mon, Mar 17, 2025 at 2:43 PM Cristian Rodríguez <cristian@rodriguez.im> wrote:
>
>> On Mon, Mar 17, 2025 at 9:52 AM Frédéric Bérat <fberat@redhat.com> wrote:
>> >
>> > - Create the __inet_ntop_chk routine that verifies that the builtin size
>> > of the destination buffer is at least as big as the size given by the
>> > user.
>>
>> > +const char *
>> > +__inet_ntop_chk (int af, const void *src, char *dst,
>> > +                socklen_t size, size_t dst_size)
>> > +{
>> > +  if (size > dst_size)
>> > +    __chk_fail ();
>> > +
>>
>> Just a tiny suggestion/request.  __chk_fail (); is very generic and
>> user unfriendly, please use something like __libc_fatal("inet_ntop
>> destination buffer is too small") or something meaningful.
>
> Fair enough, I merely followed the pattern I've seen on other checks,
> I'm fine to change that.  I'll wait for a bit more feedback before
> sending a v2.

We should fix this more globally, and not for just for this function.
You can keep using __chk_fail for this change.

Thanks,
Florian



More information about the Libc-alpha mailing list