This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 0/4] readelf: Fixes for IN_RANGE


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]