Prevent looping in archives
[deliverable/binutils-gdb.git] / bfd / coff-alpha.c
index 58d4e1d1fbe536db2255cd811baa24d0e4ddef70..7478f2f320d39a81f2d390de36ce44b42fd756ba 100644 (file)
@@ -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);
This page took 0.025196 seconds and 4 git commands to generate.