From: Alan Modra Date: Wed, 18 Dec 2019 12:33:28 +0000 (+1030) Subject: ld signed overflow fix X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=599956cfe164ca2f4f7d04b90aee1db98930a023;p=binutils-gdb.git ld signed overflow fix * pe-dll.c (pe_get32, pe_as32): Avoid signed overflow. --- diff --git a/ld/ChangeLog b/ld/ChangeLog index 417bb151c15..7c36a5dae1c 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,7 @@ +2019-12-18 Alan Modra + + * pe-dll.c (pe_get32, pe_as32): Avoid signed overflow. + 2019-12-17 Alan Modra * testsuite/ld-avr/lds-mega.d: Adjust symbols to suit objdump change. diff --git a/ld/pe-dll.c b/ld/pe-dll.c index 4679fca6d52..7f45546aaf5 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