Re: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

2011-03-06 Thread Michael Snyder
DJ Delorie wrote: Bizzare, the problem isn't the hash loop, it's the error handler at the end! It never uses [30] for the main loop, only if you give it a number between 0xfffb and 0x - and in the case where it would use [30], it's supposed to abort anyway. I couldn't figure out why

Re: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

2011-03-03 Thread DJ Delorie
> I was just wondering whether now would be a good time to mention Probably not, gcc being in stage 4 and all...

Re: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

2011-03-03 Thread Dave Korn
On 03/03/2011 23:00, Mike Stump wrote: > On Mar 3, 2011, at 2:26 PM, Michael Snyder wrote: >> DJ Delorie wrote: As written, the function will access element [30] of a 30-element array. >>> Um, no? >> Y-uh-huh! > > fight fight fight... :-) There can be only one. I was just wondering wheth

Re: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

2011-03-03 Thread Michael Snyder
Mike Stump wrote: On Mar 3, 2011, at 2:26 PM, Michael Snyder wrote: DJ Delorie wrote: As written, the function will access element [30] of a 30-element array. Um, no? Y-uh-huh! fight fight fight... :-) There can be only one. Oh, did I forget the smiley? ;-)

Re: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

2011-03-03 Thread Mike Stump
On Mar 3, 2011, at 2:26 PM, Michael Snyder wrote: > DJ Delorie wrote: >>> As written, the function will access element [30] of a 30-element array. >> Um, no? > > Y-uh-huh! fight fight fight... :-) There can be only one.

Re: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

2011-03-03 Thread DJ Delorie
Bizzare, the problem isn't the hash loop, it's the error handler at the end! It never uses [30] for the main loop, only if you give it a number between 0xfffb and 0x - and in the case where it would use [30], it's supposed to abort anyway. I couldn't figure out why your patch worked

Re: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

2011-03-03 Thread Michael Snyder
DJ Delorie wrote: As written, the function will access element [30] of a 30-element array. Um, no? unsigned int mid = low + (high - low) / 2; This can never give mid == high unless low == high, which won't happen in that loop. The math wants to search everything from (including) low to

Re: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

2011-03-03 Thread Michael Snyder
DJ Delorie wrote: As written, the function will access element [30] of a 30-element array. Um, no? Y-uh-huh! unsigned int mid = low + (high - low) / 2; This can never give mid == high unless low == high, which won't happen in that loop. The math wants to search everything from (incl

Re: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

2011-03-03 Thread DJ Delorie
> As written, the function will access element [30] of a 30-element array. Um, no? unsigned int mid = low + (high - low) / 2; This can never give mid == high unless low == high, which won't happen in that loop. The math wants to search everything from (including) low to (excluding) high.

[RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

2011-03-03 Thread Michael Snyder
As written, the function will access element [30] of a 30-element array. OK? 2011-03-03 Michael Snyder * hashtab.c (higher_prime_index): Prevent array overrun. Index: hashtab.c === RCS file: /cvs/src/src/libiberty/hasht