]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
iso9660: Handle multiple slashes after dot dot
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 19 Apr 2026 20:02:29 +0000 (22:02 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 19 Apr 2026 20:16:16 +0000 (22:16 +0200)
The isofile_gen_utility_names function normalizes directories, including
dot dot directory entries. If such an entry has multiple slahes and leads
to the top directory, then the new path erroneously becomes absolute.

Skip multiple slashes.

If rp is not NULL, then it points to a slash already. Takes this into
account to unify the rp and dirname cases a bit more.

Resolves #2937.

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

index 3d350f5afab9b8c367135a915d7199598f2441c0..4df9d12a27d93bac53005a2bbaa418005ddadb56 100644 (file)
@@ -4910,16 +4910,19 @@ isofile_gen_utility_names(struct archive_write *a, struct isofile *file)
                                 *     --> 'dir/dir2/'
                                 */
                                char *rp = p -1;
+                               size_t off;
+                               for (off = 4; p[off] == '/'; off++)
+                                       ;
                                while (rp >= dirname) {
                                        if (*rp == '/')
                                                break;
                                        --rp;
                                }
                                if (rp > dirname) {
-                                       memmove(rp, p + 3, strlen(p + 3) + 1);
+                                       memmove(rp + 1, p + off, strlen(p + off) + 1);
                                        p = rp;
                                } else {
-                                       memmove(dirname, p + 4, strlen(p + 4) + 1);
+                                       memmove(dirname, p + off, strlen(p + off) + 1);
                                        p = dirname;
                                }
                        } else