This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Using strlcpy if target OS allows it
On Mon, Apr 18, 2005 at 12:13:19PM +0200, Marc Espie wrote:
> I forgot one extra important point. I am in the situation of someone
> needing to implement something on a third party system.
>
> Even though I am an OpenBSD developer, there's absolutely no way I am
> ever going to convince Theo that this warning should be disabled. So,
> I have to work with this and make the best libstdc++ I can out of this.
Maybe I spoke too soon.
Clearly a local patch to use strlcpy instead of strcpy in the testsuite
doesn't hurt performance of the installed library, and other uses of
strcpy in the include headers are all equivalent to strdup: allocate
strlen()+1 elements and copy to it. Is strdup a blessed routine on
OpenBSD? If so, you could use it (and avoid my objection to strlcpy:
for every use of strcpy the buffer is exactly the right size, so using
strlcpy to check for overflow is wasteful).