[PATCH 0/4] readelf: Fixes for IN_RANGE

Nick Clifton nickc@redhat.com
Tue Nov 5 14:58:00 GMT 2019


Hi Christian,

On 05/11/2019 14:25, Nick Clifton wrote:
>> +	* readelf.c (IN_RANGE): Fix off by one error
>> +	whilst checking reloc location against section size.
> 
>>  #define IN_RANGE(START,END,ADDR,SIZE)		\
>> -  (((ADDR) >=3D (START)) && ((ADDR) < (END)) && ((ADDR) + (SIZE) < (END)))
>> +  (((ADDR) >=3D (START)) && ((ADDR) < (END)) && ((ADDR) + (SIZE) <=3D (END=
>> )))
> 
> This is wrong.

Doh!  No, I am wrong in saying that you were wrong.  *sigh*

I think that what we need here is a comment to make it clear what the
macro is doing.  Something like:

  /* Evaluates to to TRUE if the region ADDR..ADDR+SIZE-1 is contained
     within the address range START..END-1.  */

What do you think ?

Cheers
  Nick




More information about the Binutils mailing list