summaryrefslogtreecommitdiff
path: root/bfd/archive.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2013-02-15 15:53:42 +0000
committerNick Clifton <nickc@redhat.com>2013-02-15 15:53:42 +0000
commit088f7bb95c7a7c0491039d43970c2ad39ff1d8e1 (patch)
tree3076a14d669ed702c0887aa7bd867b5f6f482805 /bfd/archive.c
parent214383dd76c20399a8212ec30d98b70b76490af3 (diff)
Allow for some recursion when scanning archives.
Diffstat (limited to 'bfd/archive.c')
-rw-r--r--bfd/archive.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/bfd/archive.c b/bfd/archive.c
index 4b6a81cb0f..7df5c5443a 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -618,6 +618,7 @@ bfd *
_bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos)
{
static file_ptr prev_filepos;
+ static unsigned int dup_filepos_count = 0;
struct areltdata *new_areldata;
bfd *n_nfd;
char *filename;
@@ -625,12 +626,17 @@ _bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos)
n_nfd = _bfd_look_for_bfd_in_cache (archive, filepos);
if (n_nfd)
return n_nfd;
- /* PR15140: Prevent an inifnite recursion scanning a malformed nested archive. */
+ /* PR15140: Prevent an infinite recursion scanning a malformed nested archive. */
if (filepos == prev_filepos)
{
- bfd_set_error (bfd_error_malformed_archive);
- return NULL;
+ if (++ dup_filepos_count > 100)
+ {
+ bfd_set_error (bfd_error_malformed_archive);
+ return NULL;
+ }
}
+ else
+ dup_filepos_count = 0;
if (0 > bfd_seek (archive, filepos, SEEK_SET))
return NULL;