diff options
author | Warner Losh <imp@FreeBSD.org> | 2023-10-27 16:11:29 +0000 |
---|---|---|
committer | Warner Losh <imp@FreeBSD.org> | 2023-10-27 16:13:50 +0000 |
commit | 5e50a0f39ff7fce651a0d36ee686740b70ad9f0e (patch) | |
tree | 30f3c11db1c8de397c588c1212def330485fe063 | |
parent | afd155c72bf65c056d19473569cc78c6e5807b3b (diff) | |
download | src-5e50a0f39ff7fce651a0d36ee686740b70ad9f0e.tar.gz src-5e50a0f39ff7fce651a0d36ee686740b70ad9f0e.zip |
strlcpy/strlcat: Remove references to snprintf
While strlcpy and snprintf are somewhat similar, there's big differences
between strlcat and snprintf which leads to confusion. Remove the
comparison, since it's ultimately not that useful: the snprintf man page
has similar language to strlcpy, so it doesn't provide a better
reference. The two implementations are otherwise unrelated.
Reviewed by: bcr
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D27228
-rw-r--r-- | lib/libc/string/strlcpy.3 | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/lib/libc/string/strlcpy.3 b/lib/libc/string/strlcpy.3 index 148afcbbd2bd..89c9d62c5a25 100644 --- a/lib/libc/string/strlcpy.3 +++ b/lib/libc/string/strlcpy.3 @@ -25,7 +25,7 @@ .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd May 1, 2020 +.Dd October 27, 2023 .Dt STRLCPY 3 .Os .Sh NAME @@ -45,9 +45,11 @@ The .Fn strlcpy and .Fn strlcat -functions copy and concatenate strings with the -same input parameters and output result as -.Xr snprintf 3 . +functions copy and concatenate strings with the same input parameters and output result as +.Xr strcpy 3 +and +.Xr strcat 3 +with proper overflow protection. They are designed to be safer, more consistent, and less error prone replacements for the easily misused functions .Xr strncpy 3 @@ -100,22 +102,7 @@ and .Fa dst strings overlap, the behavior is undefined. .Sh RETURN VALUES -Besides quibbles over the return type -.Pf ( Va size_t -versus -.Va int ) -and signal handler safety -.Pf ( Xr snprintf 3 -is not entirely safe on some systems), the -following two are equivalent: -.Bd -literal -offset indent -n = strlcpy(dst, src, len); -n = snprintf(dst, len, "%s", src); -.Ed -.Pp -Like -.Xr snprintf 3 , -the +The .Fn strlcpy and .Fn strlcat |