bug-gnulib
[Top][All Lists]
Advanced

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

Re: [Bug-gnulib] strnstr


From: Bruno Haible
Subject: Re: [Bug-gnulib] strnstr
Date: Wed, 29 Sep 2004 21:16:55 +0200
User-agent: KMail/1.5

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.

However, your use in GnuTLS appears to be different. You are using
functions that work on pieces of buffers, i.e. on not NUL terminated
memory regions, right? If so, what is the complete list of functions
that you need? memchr(), memrchr(), memstr(), memrstr(), I guess?

Bruno





reply via email to

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