+2020-03-05 Alan Modra <amodra@gmail.com>
+
+ * archive64.c (_bfd_archive_64_bit_slurp_armap): Check parsed_size
+ against file size before allocating memory. Use bfd_alloc rather
+ than bfd_zalloc for carsym/strings memory.
+
2020-03-04 Alan Modra <amodra@gmail.com>
* elf.c (elf_fake_sections): Ensure sh_addralign is such that
bfd_byte *raw_armap = NULL;
carsym *carsyms;
bfd_size_type amt;
+ ufile_ptr filesize;
ardata->symdefs = NULL;
parsed_size = mapdata->parsed_size;
free (mapdata);
+ filesize = bfd_get_file_size (abfd);
+ if (filesize != 0 && parsed_size > filesize)
+ {
+ bfd_set_error (bfd_error_malformed_archive);
+ return FALSE;
+ }
+
if (bfd_bread (int_buf, 8, abfd) != 8)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_malformed_archive);
return FALSE;
}
- ardata->symdefs = (struct carsym *) bfd_zalloc (abfd, amt);
+ ardata->symdefs = (struct carsym *) bfd_alloc (abfd, amt);
if (ardata->symdefs == NULL)
return FALSE;
carsyms = ardata->symdefs;