https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96951

--- Comment #4 from Florian Weimer <fw at gcc dot gnu.org> ---
Thanks.

Checking for the null byte at the end (as in comment 0) currently seems the
most convenient way. Writing those additional null bytes is not entirely free.
As an industry standard, the strlcpy function has emerged as an alternative:

  if (strlcpy (p->string, s, sizeof (p->string)) >= sizeof (p->string))
    return -1;

But as you might recall, glibc consensus procedures currently prevent me from
adding support for strlcpy support to the GNU toolchain.

memccpy is already there, but *very* obscure, so I do not think that is a good
alternative.

Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill

Reply via email to