diff options
Diffstat (limited to 'bfd/compress.c')
-rw-r--r-- | bfd/compress.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/bfd/compress.c b/bfd/compress.c index 20eef95..083a7df 100644 --- a/bfd/compress.c +++ b/bfd/compress.c @@ -177,6 +177,13 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr) switch (sec->compress_status) { case COMPRESS_SECTION_NONE: + /* PR binutils/17512: Avoid malloc or file reading errors due to + ridiculous section sizes. But ignore linker created objects + with no contents (yet). */ + if (bfd_get_size (abfd) > 0 + && sz > (bfd_size_type) bfd_get_size (abfd)) + return FALSE; + if (p == NULL) { p = (bfd_byte *) bfd_malloc (sz); |