[quagga-dev 3086] Re: strlcpy implementation correct?
hasso at estpak.ee
Sat Apr 2 18:01:49 BST 2005
Andrew J. Schorr wrote:
> In lib/str.c, we have:
> #ifndef HAVE_STRLCPY
> * strlcpy is a safer version of strncpy(), checking the total
> * size of the buffer
> strlcpy(char *dst, const char *src, size_t size)
> strncpy(dst, src, size);
> return (strlen(dst));
> Is that actually correct? I thought strlcpy was supposed to guarantee
> termination with '\0' (unlike strncpy)?
> It looks like strlcat may also be incorrect...
Sure, look at toplevel comment in str.c. Replacing these have been in my
todo list, but haven't time for it yet. I have always something more
important todo ;). Feel free to replace these with any GPL'ed
Btw, Linux is the only platform which will use these. All other supported
platforms (*BSD and Solaris) have strlcpy and strlcat in libc. Many
projects have their own implementations in their libs because of that.
Elion Enterprises Ltd.
More information about the Quagga-dev