[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnulib] strnstr

From: Paul Eggert
Subject: Re: [Bug-gnulib] strnstr
Date: Wed, 29 Sep 2004 15:32:11 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Bruno Haible <address@hidden> writes:

> Simon Josefsson wrote:
>> Darwin and FreeBSD has this, and GnuTLS is using it.
> Hmm. FreeBSD has some str'n' functions that work on truncated strings,
> i.e. it always uses  MIN (strlen(s), N)  as actual length. This seems
> like a broken concept to me, because
>   - it is slower than just using strlen(s) or N as actual length,
>   - it provides the illusion of being safe, but isn't because it will
>     silently truncate strings, thus producing garbage effects at will,
>   - the common GNU concept is to allocate strings that are as long as
>     they need to be.

I agree pretty much on all these points.  The strn* stuff is
antithetical to the usual GNU style.

It may be worth mentioning that this has been a bone of contention
between the GNU/Linux folks and some of the BSD folks for quite some time.
See, for example, the thread starting here:

Linus Torvalds
Re: [open-source] Re: Wish for 2002 ...

If you have the patience to wade through that thread, you'll see why I
think Linus is right and Theo de Raadt is wrong about the strn*
functions.  (You'll also see Theo dismissing my arguments with the
comment "WHat an utter waste of timje." [sic] :-)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]