[PATCH 2/2] Add _FORTIFY_SOURCE support for inet_ntop
Florian Weimer
fweimer@redhat.com
Mon Mar 24 10:23:35 GMT 2025
* Aaron Merey:
> +__fortify_function __attribute_overloadable__ int
> +__NTH (inet_pton (int __af,
> + const char *__restrict __src,
> + __fortify_clang_overload_arg (void *, __restrict, __dst)))
> + __fortify_clang_warning_only_if_bos0_lt
> + (4, __dst, "inet_pton called with destination buffer size less than 4")
> +{
> + size_t scale = 0;
> + if (__af == AF_INET)
> + scale = 1;
> + else if (__af == AF_INET6)
> + scale = 4;
> + else
> + return __inet_pton_alias (__af, __src, __dst);
> +
> + return __glibc_fortify (inet_pton, 4, scale,
> + __glibc_objsize (__dst),
> + __af, __src, __dst);
> +};
Why not set scale to 1 and use the byte sizes directly? This looks a
bit obfuscated.
Thanks,
Florian
More information about the Libc-alpha
mailing list