[quagga-dev 3085] strlcpy implementation correct?

Andrew J. Schorr aschorr at telemetry-investments.com
Sat Apr 2 16:53:45 BST 2005


In lib/str.c, we have:

#ifndef HAVE_STRLCPY
/*
 * strlcpy is a safer version of strncpy(), checking the total
 * size of the buffer
 */
size_t
strlcpy(char *dst, const char *src, size_t size)
{
  strncpy(dst, src, size);

  return (strlen(dst));
}
#endif

Is that actually correct?  I thought strlcpy was supposed to guarantee
termination with '\0' (unlike strncpy)?

It looks like strlcat may also be incorrect...

Regards,
Andy



More information about the Quagga-dev mailing list