| Age | Commit message (Collapse) | Author | Files | Lines |
|
This is a scripted change:
$ mkdir man/;
$ mv man* man/;
$ ln -st . man/man*;
$ find share/mk/ -type f \
| xargs grep -l '^MANDIR *:=' \
| xargs sed -i '/^MANDIR *:=/s,$,/man,';
$ find share/mk/dist/ -type f \
| xargs grep -l man \
| xargs sed -i 's,man%,man/%,g';
Link: <https://lore.kernel.org/linux-man/YxcV4h+Xn7cd6+q2@pevik/T/>
Cc: Petr Vorel <pvorel@suse.cz>
Cc: Jakub Wilk <jwilk@jwilk.net>
Cc: Stefan Puiu <stefan.puiu@gmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
For these byte functions, sizeof() works as well as NITEMS(), since
CHAR_BIT == 1. However, equivalent wide-character functions need
NITEMS(), which is semantically more appropriate, and also safer (it
cannot be applied to pointers).
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
The function was changed recently to return NULL on truncation; update
the example of use accordingly.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
This makes it simpler to test the return value, and since it sets errno
to find out the reason, we don't need a complex return value.
Now that (dst == end) shouldn't happen, use ENOBUFS to report that
error.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Null character, for the terminating character of a string.
Null byte, for the padding.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
known
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Reported-by: Paul Eggert <eggert@cs.ucla.edu>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
That text could lead someone to think that it's possible to check
truncation from the return value, but it isn't.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
And put it next to strlcpy(3bsd), which is very similar to strtcpy().
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Suggested-by: Paul Eggert <eggert@cs.ucla.edu>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
For the functions that are designed to be used with utmp(5) or similar
APIs, use utmp(5) in the example, which results in a clearer example,
and also more realistic. It better clarifies how these functions are to
be used.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
This implementation resembles more strtcpy(), so the differences are
more visible. Also, it has no -1's, so it's a bit easier to implement
correctly.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Instead, document how to use mempcpy(3) well in that case.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Instead, document how to use mempcpy(3) well in that case.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Users reported complains about having so many invented functions, and
the complexity of remembering all of them.
In these two cases, open-coding mempcpy(3) isn't so bad. In fact, it's
quite readable. It has the problem of type safety, since this function
accepts almost everything, but let users come up with a wrapper if they
need it; it's not like you would be calling these functions often.
Document how to use mempcpy(3) well in those cases.
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
By setting the terminating null byte via a stpcpy(dst, "") call, the
last byte is also protected by _FORTIFY_SOURCE.
Reported-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Especially for validating input, code should fail, not truncate.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Add this new truncating string-copying function. It intends to fully
replace strlcpy(3), which has important bugs (documented in the
preceeding commit).
It is almost identical to Linux kernel's strscpy(9), so reduce the
documentation of strscpy(9) in this page to the minimum, giving
preference to strtcpy(3). Provide a reference implementation, since no
libc provides it.
Providing an easy, safe, and relatively fast truncating string-copying
function should prevent users from rolling their own, in which they
might introduce bugs accidentally. We already made enough mistakes
while discussing these functions, so it's certainly not something that
should be written often.
Cc: Paul Eggert <eggert@cs.ucla.edu>
Cc: Jonny Grant <jg@jguk.org>
Cc: DJ Delorie <dj@redhat.com>
Cc: Matthew House <mattlloydhouse@gmail.com>
Cc: Oskari Pirhonen <xxc3ncoredxx@gmail.com>
Cc: Thorsten Kukuk <kukuk@suse.com>
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: Zack Weinberg <zack@owlfolio.org>
Cc: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Cc: Xi Ruoyao <xry111@xry111.site>
Cc: Stefan Puiu <stefan.puiu@gmail.com>
Cc: Andreas Schwab <schwab@linux-m68k.org>
Cc: Guillem Jover <guillem@hadrons.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Also point to BUGS from other sections that talk about these functions.
These functions are doomed due to the design decision of mirroring
snprintf(3)'s return value. They must return strlen(src), which makes
them terribly slow, and vulnerable to DoS if an attacker can control
strlen(src).
A better design would have been to return -1 when truncating.
Reported-by: Paul Eggert <eggert@cs.ucla.edu>
Cc: Jonny Grant <jg@jguk.org>
Cc: DJ Delorie <dj@redhat.com>
Cc: Matthew House <mattlloydhouse@gmail.com>
Cc: Oskari Pirhonen <xxc3ncoredxx@gmail.com>
Cc: Thorsten Kukuk <kukuk@suse.com>
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: Zack Weinberg <zack@owlfolio.org>
Cc: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Cc: Xi Ruoyao <xry111@xry111.site>
Cc: Stefan Puiu <stefan.puiu@gmail.com>
Cc: Andreas Schwab <schwab@linux-m68k.org>
Cc: Guillem Jover <guillem@hadrons.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
The compiler will sometimes optimize them to normal *cpy(3) functions,
since the length of dst is usually known, if the previous *cpy(3) is
visible to the compiler. And they provide for cleaner code. If you
know that they'll get optimized, you could use them.
Cc: Paul Eggert <eggert@cs.ucla.edu>
Cc: Jonny Grant <jg@jguk.org>
Cc: DJ Delorie <dj@redhat.com>
Cc: Matthew House <mattlloydhouse@gmail.com>
Cc: Oskari Pirhonen <xxc3ncoredxx@gmail.com>
Cc: Thorsten Kukuk <kukuk@suse.com>
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: Zack Weinberg <zack@owlfolio.org>
Cc: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Cc: Xi Ruoyao <xry111@xry111.site>
Cc: Stefan Puiu <stefan.puiu@gmail.com>
Cc: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Don't start this paragraph with a fragment. Also, remove "by nature",
which is superfluous.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
provided by any libc
Reported-by: Jonny Grant <jg@jguk.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Put the text after the function names, like the rest of the page.
Suggested-by: Jonny Grant <jg@jguk.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Remove superfluous words.
Suggested-by: Jonny Grant <jg@jguk.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
null bytes
The previous wording could be interpreted as if the nulls were already
in place. Clarify that it's this function which pads with null bytes.
Also, it copies "characters" from the src string. That's a bit more
specific than copying "bytes", and makes it clearer that the terminating
null byte in src is not part of the copy.
Suggested-by: Jonny Grant <jg@jguk.org>
Cc: DJ Delorie <dj@redhat.com>
Cc: Matthew House <mattlloydhouse@gmail.com>
Cc: Oskari Pirhonen <xxc3ncoredxx@gmail.com>
Cc: Thorsten Kukuk <kukuk@suse.com>
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: Zack Weinberg <zack@owlfolio.org>
Cc: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Cc: Paul Eggert <eggert@cs.ucla.edu>
Cc: Xi Ruoyao <xry111@xry111.site>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
These copy *from* a string. But the destination is a simple character
sequence within an array; not a string.
Suggested-by: DJ Delorie <dj@redhat.com>
Acked-by: Oskari Pirhonen <xxc3ncoredxx@gmail.com>
Cc: Jonny Grant <jg@jguk.org>
Cc: Matthew House <mattlloydhouse@gmail.com>
Cc: Thorsten Kukuk <kukuk@suse.com>
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: Zack Weinberg <zack@owlfolio.org>
Cc: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Cc: Paul Eggert <eggert@cs.ucla.edu>
Cc: Xi Ruoyao <xry111@xry111.site>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
We're trying to "standardize" on a paragraphing macro from the three
equivalent ones (P, PP, LP). We (somewhat arbitrarily) agreed on P.
Scripted change:
$ find man* -type f | xargs sed -i '/\.PP/s/PP/P/'
$ find man* -type f | xargs sed -i '/\.LP/s/LP/P/'
Suggested-by: "G. Branden Robinson" <branden@debian.org>
Cc: Ingo Schwarze <schwarze@openbsd.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Suggested-by: "Serge E. Hallyn" <serge@hallyn.com>
Acked-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Remove non-breaking space (0xC2A0) that accidentally landed in the
source of some string pages. Replace by a normal space (0x20).
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
On some of the commas: There are a few of instances of
Subject verb object partclause, advphrase.
For example:
This function catenates the input character sequence
| subject | verb | object |
contained in a null-padded wixed-width buffer,
| participial clause |
into a destination string.
| adverbial phrase |
Imagining the participial clause away, there shouldn't be a comma
preceding the restrictive adverbial phrase: The input character sequence
is really, always catenated into a destination string; that is
essential. For example:
This function catenates the input character sequence into
a destination string.
The participial clause, being non-restrictive---there is but one input
character sequence that could be meant---, should be enclosed by commas.
That is the existing comma's purpose and doesn't work without the added,
first comma.
Cc: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Signed-off-by: Lennart Jablonka <humm@ljabl.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
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>
|
|
[Clean up in preparation for "MR sed".]
Drop spurious, nilpotent uses of *roff `\c` escape sequence.
Quoting groff_man_style(7):
\c End a text line without inserting space or attempting a break.
Normally, if filling is enabled, the end of a text line is
treated like a space; an output line _may_ be broken there (if
not, an adjustable space is inserted); if filling is disabled,
the line _will_ be broken there, as in .EX/.EE examples. The
next line is interpreted as usual and can include a macro call
(contrast with \newline). \c is useful when three font styles
are needed in a single word, as in a command synopsis.
Signed-off-by: G. Branden Robinson <g.branden.robinson@gmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
- Use the dummy character to avoid warnings in examples.
- Re-enable the warning.
Suggested-by: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Reported-by: groff(1) (`make build-catman-troff`)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
- Don't crash on invalid input. That should be done in a wrapper, if
wanted.
- Accept NULL as input, since that allows chaining with stpeprintf().
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Reported-by: mandoc(1) (make lint-man-mandoc)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
This improves readability in the source code, since it delimits where
the escape sequence ends.
Cc: наб <nabijaczleweli@nabijaczleweli.xyz>
Cc: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Cc: Brian Inglis <Brian.Inglis@Shaw.ca>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Typos found with codespell.
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
And give stpecpy() with the semantics of stpecpyx().
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Reported-by: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
Reported-by: Stefan Puiu <stefan.puiu@gmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
This is an opportunity to use consistent language across the
documentation for all string-copying functions.
It is also easier to show the similarities and differences between all
of the functions, so that a reader can use this page to know which
function is needed for a given task.
Alternative functions not provided by libc have been given in the same
page, with reference implementations.
Cc: Martin Sebor <msebor@redhat.com>
Cc: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Cc: Douglas McIlroy <douglas.mcilroy@dartmouth.edu>
Cc: Jakub Wilk <jwilk@jwilk.net>
Cc: Serge Hallyn <serge@hallyn.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Andrew Pinski <pinskia@gmail.com>
Cc: Stefan Puiu <stefan.puiu@gmail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|