aboutsummaryrefslogtreecommitdiffstats
path: root/man3/strncpy.3
diff options
context:
space:
mode:
Diffstat (limited to 'man3/strncpy.3')
-rw-r--r--man3/strncpy.321
1 files changed, 15 insertions, 6 deletions
diff --git a/man3/strncpy.3 b/man3/strncpy.3
index 619251b011..b1fb165c33 100644
--- a/man3/strncpy.3
+++ b/man3/strncpy.3
@@ -23,14 +23,17 @@ Standard C library
.nf
.B #include <string.h>
.PP
-.BI "char *strncpy(char " dest "[restrict ." n "], \
-const char " src "[restrict ." n ],
-.BI " size_t " n );
+.BI "[[deprecated]] char *strncpy(char " dest "[restrict ." n ],
+.BI " const char " src "[restrict ." n "], \
+size_t " n );
.fi
.SH DESCRIPTION
-.BI Note: " This is probably not the function you want to use."
+.BI Note: " This is not the function you want to use."
For safe string copying, see
.BR strlcpy (3bsd).
+For copying a string into a fixed-length buffer with zeroing of the rest,
+see
+.BR stpncpy (3).
.PP
The
.BR strncpy ()
@@ -75,7 +78,11 @@ while ensuring that unused bytes in the destination buffer are zeroed out
(perhaps to prevent information leaks if the buffer is to be
written to media or transmitted to another process via an
interprocess communication technique).
-But see CAVEATS below.
+But
+.BR stpncpy (3)
+is better for this purpose,
+since it detects truncation.
+See CAVEATS below.
.SH RETURN VALUE
The
.BR strncpy ()
@@ -112,7 +119,9 @@ It's probably better to explicitly call
.BR bzero (3)
and
.BR memccpy (3),
-since that allows detecting truncation.
+or
+.BR stpncpy (3)
+since they allow detecting truncation.
.SH SEE ALSO
.BR bzero (3),
.BR memccpy (3),