ld signed overflow fix
Alan Modra
amodra@gmail.com
Wed Dec 18 12:51:00 GMT 2019
* 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
More information about the Binutils
mailing list