]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
iso9660: Fix ../../ path normalization 2968/head
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 19 Apr 2026 20:10:10 +0000 (22:10 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 19 Apr 2026 20:17:13 +0000 (22:17 +0200)
The function isofile_gen_utility_names could resolve .. directory
entries in a way that dirname will start with "../". If this happens,
the while-loop is unable to detect this because it forwards until the
cursor detects a slash again.

Fix this by also taking "../" at the beginning into account. Such an
entry can happen if "../../" points before the top directory.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
libarchive/archive_write_set_format_iso9660.c

index 4df9d12a27d93bac53005a2bbaa418005ddadb56..1e293588bb91389bc1d6bc4dde8f83dbe81cbc89 100644 (file)
@@ -4927,6 +4927,12 @@ isofile_gen_utility_names(struct archive_write *a, struct isofile *file)
                                }
                        } else
                                p++;
+               } else if (p == dirname && p[0] == '.' && p[1] == '.' && p[2] == '/') {
+                       size_t off;
+                       for (off = 3; p[off] == '/'; off++)
+                               ;
+                       memmove(dirname, p + off, strlen(p + off) + 1);
+                       p = dirname;
                } else
                        p++;
        }