public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* ld signed overflow fix
@ 2019-12-18 12:51 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2019-12-18 12:51 UTC (permalink / raw)
  To: binutils

	* pe-dll.c (pe_get32, pe_as32): Avoid signed overflow.

diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index 4679fca6d5..7f45546aaf 100644
--- a/ld/pe-dll.c
+++ b/ld/pe-dll.c
@@ -3289,7 +3289,7 @@ pe_get32 (bfd *abfd, int where)
 
   bfd_seek (abfd, (file_ptr) where, SEEK_SET);
   bfd_bread (b, (bfd_size_type) 4, abfd);
-  return b[0] + (b[1] << 8) + (b[2] << 16) + (b[3] << 24);
+  return b[0] + (b[1] << 8) + (b[2] << 16) + ((unsigned) b[3] << 24);
 }
 
 static unsigned int
@@ -3297,7 +3297,7 @@ pe_as32 (void *ptr)
 {
   unsigned char *b = ptr;
 
-  return b[0] + (b[1] << 8) + (b[2] << 16) + (b[3] << 24);
+  return b[0] + (b[1] << 8) + (b[2] << 16) + ((unsigned) b[3] << 24);
 }
 
 bfd_boolean

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-12-18 12:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-18 12:51 ld signed overflow fix Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).