diff options
author | Alan Modra <amodra@gmail.com> | 2021-12-28 22:51:55 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2022-01-18 11:19:14 +1030 |
commit | 48e3e6aec8a4f37d00ea6c0da3ab45e76490e3db (patch) | |
tree | 1960fee8dd31a1aa702c126fa6a7d05ecb6fb55e /bfd/archive.c | |
parent | e29de63f0d160268850d79fa29b6c0b1ee65fd75 (diff) | |
download | gdb-48e3e6aec8a4f37d00ea6c0da3ab45e76490e3db.zip gdb-48e3e6aec8a4f37d00ea6c0da3ab45e76490e3db.tar.gz gdb-48e3e6aec8a4f37d00ea6c0da3ab45e76490e3db.tar.bz2 |
Check thin archive element file size against archive header
Makes it a little less likely for someone to break their thin archives.
* archive.c (_bfd_get_elt_at_filepos): Check thin archive
element file size.
Diffstat (limited to 'bfd/archive.c')
-rw-r--r-- | bfd/archive.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/bfd/archive.c b/bfd/archive.c index 9ad61ad..ffaec7e 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -717,7 +717,17 @@ _bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos, open the external file as a bfd. */ bfd_set_error (bfd_error_no_error); n_bfd = open_nested_file (filename, archive); - if (n_bfd == NULL) + if (n_bfd != NULL) + { + ufile_ptr size = bfd_get_size (n_bfd); + if (size != 0 && size != new_areldata->parsed_size) + { + bfd_set_error (bfd_error_malformed_archive); + bfd_close (n_bfd); + n_bfd = NULL; + } + } + else { switch (bfd_get_error ()) { |