tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: warn against strcpy(3)
Date: Mon, 3 Oct 2022 23:05:32 -0400
From: Jan Schaumann <jschauma%netmeister.org@localhost>
Message-ID: <20221004030532.GP11969%netmeister.org@localhost>
| On macOS, the strcpy(3) manual page contains the
| following "Admonishment" prominently displayed
| immediately after the Synopsis:
|
| YOU SHOULD ALMOST CERTAINLY USE strlcpy() INSTEAD.
| See "Examples" below.
How ugly and useless. I have no objection to adding a
warning about the dangers of improperly using strcpy() (etc)
but I do not believe suggesting (almost demanding, in upper
case no less) use of strlcpy() is the correct thing to do.
strlcpy() has its own problems, just different ones than
strcpy() has, as does strncpy() (different yet again).
The only answer to this is to code properly, and suggesting
how this can be accomplished, perhaps using asprintf() rather
than any of the str*cpy() functions, would not be a bad thing.
Shouting at programmers who don't use the strl*() functions
is unacceptable however.
kre
Home |
Main Index |
Thread Index |
Old Index