summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Jablonka <humm@ljabl.com>2023-07-28 19:22:10 +0000
committerAlejandro Colomar <alx@kernel.org>2023-07-29 00:03:54 +0200
commitd56554f0d693c4c0c63c15f0ae1c437005b16666 (patch)
tree8c8f4f2b1db7d771a02d6b297c06bf58482487bc
parentd7ec31628938c8261a1f00d3c273de4f7407ccee (diff)
string_copying.7: don't grant strl{cpy,cat} magic
A function can't check whether a pointer points to the start of a string. What it certainly can do is to keep reading until you either find a null byte or read the secret key that lies adjacent in memory and post it to your favorite mailing list. strlcpy and strlcat behave the exact same way any other function accepting a string behaves: If you don't pass a string, the behavior is undefined. And that, I believe, does not deserve a special mention here, seeing as all the other string functions don't get such a mention either. Link: <https://lore.kernel.org/linux-man/ZMQVYtquNN-s0IJr@beryllium/T/#u> Signed-off-by: Lennart Jablonka <humm@ljabl.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
-rw-r--r--man7/string_copying.76
1 files changed, 1 insertions, 5 deletions
diff --git a/man7/string_copying.7 b/man7/string_copying.7
index ab9199a68..34031ea02 100644
--- a/man7/string_copying.7
+++ b/man7/string_copying.7
@@ -223,8 +223,7 @@ It only requires to check for truncation once after all chained calls.
.BR strlcpy (3bsd)
and
.BR strlcat (3bsd)
-are designed to crash if the input string is invalid
-(doesn't contain a terminating null byte).
+are similar, but less efficient when chained.
.IP \[bu]
.BR stpncpy (3)
and
@@ -410,9 +409,6 @@ isn't large enough to hold the copy,
the resulting string is truncated
(but it is guaranteed to be null-terminated).
They return the length of the total string they tried to create.
-These functions force a SIGSEGV if the
-.I src
-pointer is not a string.
.IP
.BR stpecpy (3)
is a simpler alternative to these functions.