aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2013-02-15 18:26:06 +0000
committerH.J. Lu <hjl.tools@gmail.com>2013-02-15 18:26:06 +0000
commit989fbeffb248dde7a9a24ad8ac9f7a76b435a807 (patch)
treea83af43847c3ef77b3fb564e3f273d6f0b623a64 /bfd
parentf1dd87fcafe276824123bdc5d4a4e2bd79495662 (diff)
downloadgdb-989fbeffb248dde7a9a24ad8ac9f7a76b435a807.zip
gdb-989fbeffb248dde7a9a24ad8ac9f7a76b435a807.tar.gz
gdb-989fbeffb248dde7a9a24ad8ac9f7a76b435a807.tar.bz2
Don't allow a nested archive pointing to itself
PR binutils/15151 * archive.c (_bfd_find_nested_archive): Don't allow a nested archive pointing to itself. (_bfd_get_elt_at_filepos): Revert the last 2 changes.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog7
-rw-r--r--bfd/archive.c21
2 files changed, 14 insertions, 14 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index b65b234..72d12ef 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2013-02-15 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR binutils/15151
+ * archive.c (_bfd_find_nested_archive): Don't allow a nested
+ archive pointing to itself.
+ (_bfd_get_elt_at_filepos): Revert the last 2 changes.
+
2013-02-15 Nick Clifton <nickc@redhat.com>
PR binutils/15140
diff --git a/bfd/archive.c b/bfd/archive.c
index 7df5c54..8cc6bf2 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -379,6 +379,13 @@ _bfd_find_nested_archive (bfd *arch_bfd, const char *filename)
bfd *abfd;
const char *target;
+ /* PR 15140: Don't allow a nested archive pointing to itself. */
+ if (filename_cmp (filename, arch_bfd->filename) == 0)
+ {
+ bfd_set_error (bfd_error_malformed_archive);
+ return NULL;
+ }
+
for (abfd = arch_bfd->nested_archives;
abfd != NULL;
abfd = abfd->archive_next)
@@ -617,8 +624,6 @@ _bfd_append_relative_path (bfd *arch, char *elt_name)
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;
@@ -626,17 +631,6 @@ _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 infinite recursion scanning a malformed nested archive. */
- if (filepos == prev_filepos)
- {
- 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;
@@ -645,7 +639,6 @@ _bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos)
return NULL;
filename = new_areldata->filename;
- prev_filepos = filepos;
if (bfd_is_thin_archive (archive))
{