From 22d275999daf2b9e622bb34ec1c883a323417189 Mon Sep 17 00:00:00 2001 From: Richard Swingwood Date: Tue, 9 Dec 2025 13:32:34 +0000 Subject: [PATCH] [FS] 9P read_file cursor check --- kernel/filesystem/virtio_9p_pci.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/filesystem/virtio_9p_pci.cpp b/kernel/filesystem/virtio_9p_pci.cpp index e2d5dccc..704a6ae1 100644 --- a/kernel/filesystem/virtio_9p_pci.cpp +++ b/kernel/filesystem/virtio_9p_pci.cpp @@ -85,9 +85,9 @@ FS_RESULT Virtio9PDriver::open_file(const char* path, file* descriptor){ } size_t Virtio9PDriver::read_file(file *descriptor, void* buf, size_t size){ - if (descriptor->cursor > size) return 0; module_file *mfile = (module_file*)chashmap_get(open_files, &descriptor->id, sizeof(uint64_t)); if (!mfile) return 0; + if (descriptor->cursor > mfile->file_size) return 0; if (size > mfile->file_size-descriptor->cursor) size = mfile->file_size-descriptor->cursor; memcpy(buf, (void*)(mfile->buffer + descriptor->cursor), size); return size;