fix: reject opening directories as files in ext2 and fat32, add mbrtowc to libc

This commit is contained in:
2026-08-30 09:50:11 +02:00
parent fdbb233cd3
commit fd397ac41d
5 changed files with 28 additions and 1 deletions
+1 -1
View File
@@ -12,4 +12,4 @@
#pragma once
#define MONTAUK_BUILD_NUMBER 182
#define MONTAUK_BUILD_NUMBER 184
+7
View File
@@ -1202,6 +1202,13 @@ namespace Fs::Ext2 {
Inode inode;
if (!TraversePath(self, path, &inodeNum, &inode)) return -1;
// Directories are not openable as files, matching the ramdisk. A
// handle on one would fail every read/write anyway, and userspace
// stat() falls back to open() when it cannot get real metadata:
// succeeding here classified every directory as a regular file and
// GCC's include-path setup then rejected them as "not a directory".
if ((inode.i_mode & IMODE_TYPE_MASK) == IMODE_DIR) return -1;
for (int i = 0; i < MaxFilesPerInstance; i++) {
if (!self.files[i].inUse) {
self.files[i].inUse = true;
+4
View File
@@ -955,6 +955,10 @@ namespace Fs::Fat32 {
ParsedEntry entry;
if (!TraversePath(inst, path, &entry)) return -1;
// Directories are not openable as files; see the matching note in
// Ext2::OpenImpl (userspace stat() falls back to open()).
if ((entry.attributes & ATTR_DIRECTORY) != 0) return -1;
// Find a free file handle
auto& self = g_instances[inst];
for (int i = 0; i < MaxFilesPerInstance; i++) {