Skip to content

Commit

Permalink
Fix use-after-free error when parsing a corrupt nested archive.
Browse files Browse the repository at this point in the history
	PR 21787
	* archive.c (bfd_generic_archive_p): If the bfd does not have the
	correct magic bytes at the start, set the error to wrong format
	and clear the format selector before returning NULL.
  • Loading branch information
nickclifton committed Jul 19, 2017
1 parent 62a5222 commit 909e4e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions bfd/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2017-07-19 Nick Clifton <nickc@redhat.com>

PR 21787
* archive.c (bfd_generic_archive_p): If the bfd does not have the
correct magic bytes at the start, set the error to wrong format
and clear the format selector before returning NULL.

2017-07-19 Nick Clifton <nickc@redhat.com>

PR 21786
Expand Down
7 changes: 6 additions & 1 deletion bfd/archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,12 @@ bfd_generic_archive_p (bfd *abfd)
if (strncmp (armag, ARMAG, SARMAG) != 0
&& strncmp (armag, ARMAGB, SARMAG) != 0
&& ! bfd_is_thin_archive (abfd))
return NULL;
{
bfd_set_error (bfd_error_wrong_format);
if (abfd->format == bfd_archive)
abfd->format = bfd_unknown;
return NULL;
}

tdata_hold = bfd_ardata (abfd);

Expand Down

0 comments on commit 909e4e7

Please sign in to comment.