]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix issue 199; improve robustness to corrupted ISO images.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Mon, 21 Nov 2011 02:08:33 +0000 (21:08 -0500)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Mon, 21 Nov 2011 02:08:33 +0000 (21:08 -0500)
SVN-Revision: 3823

libarchive/archive_read_support_format_iso9660.c

index a2ef9299ae1c1b1cd14910d0a227ed31808a49ea..247cdd7aa749ba2fa00e6db54184e930be716794 100644 (file)
@@ -305,6 +305,8 @@ struct file_info {
                struct file_info        *first;
                struct file_info        **last;
        } rede_files;
+       /* To check a ininity loop. */
+       struct file_info        *loop_by;
 };
 
 struct heap_queue {
@@ -2839,8 +2841,14 @@ rede_add_entry(struct file_info *file)
        struct file_info *re;
 
        re = file->parent;
-       while (re != NULL && !re->re)
+       while (re != NULL && !re->re) {
+               /* Sanity check to prevent a infinity loop
+                * cause by a currupted iso file. */
+               if (re->loop_by == file)
+                       return (-1);
+               re->loop_by = file;
                re = re->parent;
+       }
        if (re == NULL)
                return (-1);