diff options
author | Alejandro Colomar <alx@kernel.org> | 2022-12-04 23:53:06 +0100 |
---|---|---|
committer | Alejandro Colomar <alx@kernel.org> | 2022-12-04 23:53:14 +0100 |
commit | 7e9030dc90eb785497b5cb3fa5aae71881a93c74 (patch) | |
tree | a621532e332976587a8f7c93907c3340e4727465 | |
parent | 413180217085dcb45ddf756511be7ad1e681cec0 (diff) |
strncpy.3: Move description of valid use up
To make it more visible; and refer CAVEATS to still discourage its use.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
-rw-r--r-- | man3/strncpy.3 | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/man3/strncpy.3 b/man3/strncpy.3 index 7587c036f..619251b01 100644 --- a/man3/strncpy.3 +++ b/man3/strncpy.3 @@ -67,6 +67,15 @@ strncpy(char *dest, const char *src, size_t n) } .EE .in +.PP +The only valid use of +.BR strncpy () +is to copy a C string to a fixed-length buffer +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. .SH RETURN VALUE The .BR strncpy () @@ -92,14 +101,6 @@ T} Thread safety MT-Safe .sp 1 .SH STANDARDS POSIX.1-2001, POSIX.1-2008, C89, C99, SVr4, 4.3BSD. -.SH NOTES -The only valid (and intended) use of -.BR strncpy () -is to copy a C string to a fixed-length buffer -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). .SH CAVEATS .BR strncpy () has a misleading name. |