This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
ld signed overflow fix
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Wed, 18 Dec 2019 23:21:35 +1030
- Subject: ld signed overflow fix
* 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