[Libguestfs] [PATCH nbdkit] server/public.c: Uninline nbdkit_strdup_intern to avoid compiler warning.
Eric Blake
eblake at redhat.com
Thu Sep 3 13:58:26 UTC 2020
On 9/3/20 4:59 AM, Richard W.M. Jones wrote:
>
> Filed upstream as:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96916
I just read the response - gcc has a valid point that not all
implementations optimize strndup() to malloc() only strnlen() bytes, but
may attempt to allocate the full size bytes. And malloc(SIZE_MAX) is
going to fail. So we _should_ fix our code: even though it happened to
work on glibc, it is not portable to POSIX
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
More information about the Libguestfs
mailing list