Dear Maintainer,

I have two remarks about:
https://man.openbsd.org/OpenBSD-5.9/strlcpy.3

(1) In the section “Return Values”, it is written:
    n = strlcpy(dst, src, len);
    n = snprintf(dst, len, "%s", src);
But len should not be a length but a size. This example can confuse
beginners. So I suggest the modifications:
    n = strlcpy(dst, src, dstsize);
    n = snprintf(dst, dstsize, "%s", src);

(2) In the section “Description”, it is written:
“They are designed to be safer, more consistent, and less error prone
replacements for the easily misused functions strncpy(3) and
strncat(3).”
It is not completely true: strncpy/strncat can copy/concatenate a
substring of src (the third parameter n means n bytes of src).
Strlcpy/strlcat cannot.

Sincerely yours,

Eric Sanchis
Associate Professor in Computer Science
University of Toulouse Capitole (IUT Rodez)
France

Reply via email to