Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140321174406.GK26358@brightrain.aerifal.cx>
Date: Fri, 21 Mar 2014 13:44:06 -0400
From: Rich Felker <dalias@...ifal.cx>
To: musl@...ts.openwall.com
Subject: Re: src/string/strstr.c, src/string/wcsstr.c: wrong estimates
 for MIN(l,63)?

On Fri, Mar 21, 2014 at 06:07:45PM +0100, Szabolcs Nagy wrote:
> * Rich Felker <dalias@...ifal.cx> [2014-03-21 12:48:17 -0400]:
> > On Fri, Mar 21, 2014 at 03:07:22PM +0100, Yves Bastide wrote:
> > > /* Fast estimate for MIN(l,63) */
> > > size_t grow = l | 63;
> > > 
> > > "grow" is thus always at least 63...
> > 
> > If you look at how grow is used on the very next line, this should
> > make sense.
> 
> the comment is wrong though
> z grows by at least max(63,l) unless end-of-string is reached

Yes, (l|63) is >= both l and 63, so it should read MAX, not MIN. The
idea is that it's useless to grow by less than l, but it's inefficient
to grow by less than some fixed threshold even if the needle is tiny.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.