:: commit 03ad4a421c7f9f65b0daf4867c5c2d3597870cb7

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

parents: 4744bdbd27

fs/iso9660: Verify directory flag before descending into subdirectory

diff --git a/common/fs/iso9660.s2.c b/common/fs/iso9660.s2.c
index afc10d19..2ba14c06 100644
--- a/common/fs/iso9660.s2.c
+++ b/common/fs/iso9660.s2.c
@@ -25,6 +25,7 @@ struct iso9660_file_handle {
     struct iso9660_extent *extents;
 };
 
+#define ISO9660_FLAG_DIRECTORY    0x02
 #define ISO9660_FLAG_MULTI_EXTENT 0x80
 
 #define ISO9660_FIRST_VOLUME_DESCRIPTOR 0x10
@@ -407,6 +408,14 @@ struct file_handle *iso9660_open(struct volume *vol, const char *path) {
         next_sector = entry->extent.little;
         next_size = entry->extent_size.little;
 
+        if (*path != '\0' && !(entry->flags & ISO9660_FLAG_DIRECTORY)) {
+            if (!first) {
+                pmm_free(current, current_size);
+            }
+            pmm_free(ret, sizeof(struct iso9660_file_handle));
+            return NULL;
+        }
+
         if (*path == '\0') {
             // Found the file - collect all extents for multi-extent files
             void *buffer_end = (uint8_t *)current + current_size;
tab: 248 wrap: offon