aboutsummaryrefslogtreecommitdiff
path: root/bfd/coff-alpha.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2015-11-18 22:12:23 +1030
committerAlan Modra <amodra@gmail.com>2015-11-18 22:16:24 +1030
commit4978e369fb75a8b7756bf4201668b2a9d9556286 (patch)
treefdeb0c2ed956f9b17c24e69efdf855efcc86be2a /bfd/coff-alpha.c
parent47daa70fe08c57aaafa6fe1a7e762072909d0f8f (diff)
downloadgdb-4978e369fb75a8b7756bf4201668b2a9d9556286.zip
gdb-4978e369fb75a8b7756bf4201668b2a9d9556286.tar.gz
gdb-4978e369fb75a8b7756bf4201668b2a9d9556286.tar.bz2
Prevent looping in archives
PR 19256 * archive.c (bfd_generic_openr_next_archived_file): Don't allow backward file movement via "negative" sizes. * coff-alpha.c (alpha_ecoff_openr_next_archived_file): Likewise.
Diffstat (limited to 'bfd/coff-alpha.c')
-rw-r--r--bfd/coff-alpha.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c
index 58d4e1d..7478f2f 100644
--- a/bfd/coff-alpha.c
+++ b/bfd/coff-alpha.c
@@ -2187,7 +2187,7 @@ alpha_ecoff_get_elt_at_filepos (bfd *archive, file_ptr filepos)
static bfd *
alpha_ecoff_openr_next_archived_file (bfd *archive, bfd *last_file)
{
- file_ptr filestart;
+ ufile_ptr filestart;
if (last_file == NULL)
filestart = bfd_ardata (archive)->first_file_filepos;
@@ -2208,6 +2208,12 @@ alpha_ecoff_openr_next_archived_file (bfd *archive, bfd *last_file)
BSD-4.4-style element with a long odd size. */
filestart = last_file->proxy_origin + size;
filestart += filestart % 2;
+ if (filestart <= last_file->proxy_origin)
+ {
+ /* Prevent looping. See PR19256. */
+ bfd_set_error (bfd_error_malformed_archive);
+ return NULL;
+ }
}
return alpha_ecoff_get_elt_at_filepos (archive, filestart);