:: commit 6f6564d40de94befd9c757b81ee1dd3ad2290e51

Mintsuki <mintsuki@protonmail.com> — 2026-04-17 00:19

parents: 03ad4a421c

fs/iso9660: Require matching filenames on multi-extent continuations

diff --git a/common/fs/iso9660.s2.c b/common/fs/iso9660.s2.c
index 2ba14c06..2800f708 100644
--- a/common/fs/iso9660.s2.c
+++ b/common/fs/iso9660.s2.c
@@ -425,10 +425,23 @@ struct file_handle *iso9660_open(struct volume *vol, const char *path) {
             uint64_t total_size = entry->extent_size.little;
             struct iso9660_directory_entry *e = entry;
 
+            char base_name[256];
+            if (!load_name(base_name, sizeof(base_name), entry)) {
+                base_name[0] = '\0';
+            }
+
             while (e->flags & ISO9660_FLAG_MULTI_EXTENT) {
                 struct iso9660_directory_entry *next = iso9660_next_entry(e, buffer_end);
                 if (next == NULL)
                     break;
+                // Per ECMA-119, multi-extent continuation records must share
+                // the file identifier of the first record. Refuse to splice
+                // in unrelated entries.
+                char next_name[256];
+                if (!load_name(next_name, sizeof(next_name), next)
+                 || strcmp(base_name, next_name) != 0) {
+                    break;
+                }
                 e = next;
                 extent_count++;
                 total_size += e->extent_size.little;
tab: 248 wrap: offon