diff options
author | Nick Clifton <nickc@redhat.com> | 2020-01-03 14:41:02 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2020-01-03 14:41:02 +0000 |
commit | 7a0fb7be96e0ce79e1ae429bc1ba913e5244d537 (patch) | |
tree | 2cd6d1c387030ff641bee30455eee384d516d7a9 /bfd/pef.c | |
parent | a2322019f5669e80444cdf6a8222f94a45301b3a (diff) | |
download | gdb-7a0fb7be96e0ce79e1ae429bc1ba913e5244d537.zip gdb-7a0fb7be96e0ce79e1ae429bc1ba913e5244d537.tar.gz gdb-7a0fb7be96e0ce79e1ae429bc1ba913e5244d537.tar.bz2 |
Fix potential illegal memory access failures in the BFD library by ensuring that the return value from bfd_malloc() is checked before it is used.
PR 25308
* elf-properties.c (_bfd_elf_convert_gnu_properties): Check the
return value from bfd_malloc.
* elf32-arm.c (bfd_elf32_arm_vfp11_fix_veneer_locations): Likewise.
(bfd_elf32_arm_stm32l4xx_fix_veneer_locations): Likewise.
(elf32_arm_filter_cmse_symbols): Likewise.
(elf32_arm_write_section): Likewise.
* mach-o.c (bfd_mach_o_core_fetch_environment): Likewise.
(bfd_mach_o_follow_dsym): Likewise.
* pef.c (bfd_pef_print_loader_section): Likewise.
(bfd_pef_scan_start_address): Likewise.
(bfd_pef_parse_function_stubs): Likewise.
(bfd_pef_parse_symbols): Likewise.
Diffstat (limited to 'bfd/pef.c')
-rw-r--r-- | bfd/pef.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -447,6 +447,8 @@ bfd_pef_print_loader_section (bfd *abfd, FILE *file) loaderlen = loadersec->size; loaderbuf = bfd_malloc (loaderlen); + if (loaderbuf == NULL) + return -1; if (bfd_seek (abfd, loadersec->filepos, SEEK_SET) < 0 || bfd_bread ((void *) loaderbuf, loaderlen, abfd) != loaderlen @@ -478,6 +480,9 @@ bfd_pef_scan_start_address (bfd *abfd) loaderlen = loadersec->size; loaderbuf = bfd_malloc (loaderlen); + if (loaderbuf == NULL) + goto end; + if (bfd_seek (abfd, loadersec->filepos, SEEK_SET) < 0) goto error; if (bfd_bread ((void *) loaderbuf, loaderlen, abfd) != loaderlen) @@ -753,6 +758,8 @@ bfd_pef_parse_function_stubs (bfd *abfd, (header.imported_library_count * sizeof (bfd_pef_imported_library)); imports = bfd_malloc (header.total_imported_symbol_count * sizeof (bfd_pef_imported_symbol)); + if (libraries == NULL || imports == NULL) + goto error; if (loaderlen < (56 + (header.imported_library_count * 24))) goto error; @@ -897,6 +904,8 @@ bfd_pef_parse_symbols (bfd *abfd, asymbol **csym) { codelen = codesec->size; codebuf = bfd_malloc (codelen); + if (codebuf == NULL) + goto end; if (bfd_seek (abfd, codesec->filepos, SEEK_SET) < 0) goto end; if (bfd_bread ((void *) codebuf, codelen, abfd) != codelen) @@ -908,6 +917,8 @@ bfd_pef_parse_symbols (bfd *abfd, asymbol **csym) { loaderlen = loadersec->size; loaderbuf = bfd_malloc (loaderlen); + if (loaderbuf == NULL) + goto end; if (bfd_seek (abfd, loadersec->filepos, SEEK_SET) < 0) goto end; if (bfd_bread ((void *) loaderbuf, loaderlen, abfd) != loaderlen) |