This is the mail archive of the
mailing list for the glibc project.
Re: [open-source] Re: Wish for 2002 ...
- From: Linus Torvalds <torvalds at transmeta dot com>
- To: Markus Friedl <markus at openbsd dot org>
- Cc: Paul Eggert <eggert at twinsun dot com>, <leclerc at austin dot sns dot slb dot com>, <security-audit at ferret dot lmh dot ox dot ac dot uk>, <libc-alpha at sources dot redhat dot com>, <openssh at openbsd dot org>
- Date: Fri, 11 Jan 2002 10:30:51 -0800 (PST)
- Subject: Re: [open-source] Re: Wish for 2002 ...
On Fri, 11 Jan 2002, Markus Friedl wrote:
> On Thu, Jan 10, 2002 at 04:37:27PM -0800, Paul Eggert wrote:
> > len = strlen(challenge) + strlen(PROMPT) + 1;
> > p = xmalloc(len);
> > p = '\0';
> > strlcat(p, challenge, len);
> > strlcat(p, PROMPT, len);
> > Here, the use of strlcat is redundant: strcat would do just as well,
> > and would be clearer, smaller, and no doubt faster.
> > I expect your other examples are similar.
> The code will not be converted to use strcat().
Nobody sane would convert it to strcat. The above code is CRAP.
Who the h*ll is the idiot that does "concatenate the empty string with
that string that I just took the length of", and then argues about strcat
Hello? Wake up. That code is _stupid_. It was a bit slow to use strcat in
the first place (you _know_ the length of the string), but at least it was
portable and simple, and "strcpy+strcat" at least makes sense.
But then to use a non-portable "strlcat" to concatenate an empty string,
that's just silly.
And then to try to _advocate_ being silly is just incomprehensible.
The above code is slow, ugly, non-straightforward, unportable and no more
secure than the original code was.
In short, it is just stupid code.
But hey, if you want to advocate stupid code in public, that's your
prerogative. But please don't be proud of it.