/* Support for 64-bit archives.
- Copyright (C) 1996-2020 Free Software Foundation, Inc.
+ Copyright (C) 1996-2021 Free Software Foundation, Inc.
Ian Lance Taylor, Cygnus Support
Linker support added by Mark Mitchell, CodeSourcery, LLC.
<mark@codesourcery.com>
bfd_byte *raw_armap = NULL;
carsym *carsyms;
bfd_size_type amt;
+ ufile_ptr filesize;
ardata->symdefs = NULL;
return FALSE;
/* Archives with traditional armaps are still permitted. */
- if (CONST_STRNEQ (nextname, "/ "))
+ if (startswith (nextname, "/ "))
return bfd_slurp_armap (abfd);
- if (! CONST_STRNEQ (nextname, "/SYM64/ "))
+ if (! startswith (nextname, "/SYM64/ "))
{
abfd->has_armap = FALSE;
return TRUE;
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;