[BUILDROBOT, PATCH] Fix sign-compare in dwarf.c

Jan-Benedict Glaw jbglaw@lug-owl.de
Wed Nov 19 13:17:00 GMT 2014


On Wed, 2014-11-19 21:26:10 +1030, Alan Modra <amodra@gmail.com> wrote:
> On Tue, Nov 18, 2014 at 10:08:18PM +0100, Jan-Benedict Glaw wrote:
> > -  if (len == 0 || data == end || len > (end - data))
> > +  if (len == 0 || data == end || len > (unsigned int) (end - data))
> 
> Strictly speaking that is the wrong cast.
> 
>   if (len == 0 || len > (uintptr_t) (end - data))

Quite right!  I tested that as well and committed:



2014-11-18  Jan-Benedict Glaw  <jbglaw@lug-owl.de>

binutils/
	* dwarf.c (process_extended_line_op): Fix signedness warning.

 
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index e1e2b35..7f3a568 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -416,7 +416,7 @@ process_extended_line_op (unsigned char * data,
   len = read_uleb128 (data, & bytes_read, end);
   data += bytes_read;
 
-  if (len == 0 || data == end || len > (end - data))
+  if (len == 0 || data == end || len > (uintptr_t) (end - data))
     {
       warn (_("Badly formed extended line op encountered!\n"));
       return bytes_read;


MfG, JBG

-- 
      Jan-Benedict Glaw      jbglaw@lug-owl.de              +49-172-7608481
Signature of:         "really soon now":      an unspecified period of time, likly to
the second  :                                 be greater than any reasonable definition
                                              of "soon".
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <https://sourceware.org/pipermail/binutils/attachments/20141119/374682e4/attachment.sig>


More information about the Binutils mailing list