* Check thin archive element file size against archive header
@ 2022-01-18 0:55 Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2022-01-18 0:55 UTC (permalink / raw)
To: binutils
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.
diff --git a/bfd/archive.c b/bfd/archive.c
index 9ad61adc615..ffaec7e2231 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 ())
{
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-18 0:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-18 0:55 Check thin archive element file size against archive header Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).