:: commit ec97f1ddf912224b6ce07af078ca15090a3d2343

Mintsuki <mintsuki@protonmail.com> — 2026-04-24 04:03

parents: faec367cd6

fs/file: Panic in fread when memfile resides in high memory

diff --git a/common/fs/file.s2.c b/common/fs/file.s2.c
index ad133c3d..b27e2f38 100644
--- a/common/fs/file.s2.c
+++ b/common/fs/file.s2.c
@@ -83,6 +83,9 @@ void fclose(struct file_handle *fd) {
 
 uint64_t fread(struct file_handle *fd, void *buf, uint64_t loc, uint64_t count) {
     if (fd->is_memfile) {
+        if (fd->is_high_mem) {
+            panic(false, "fread: memfile resides above 4 GiB; caller must use load_addr_64 directly");
+        }
         if (loc >= fd->size || count > fd->size - loc) {
             panic(false, "fread: attempted out of bounds read");
         }
tab: 248 wrap: offon