From e0f6f81cd511bdcec58f2314c27d2fd8cfa9e763 Mon Sep 17 00:00:00 2001 From: Ry Date: Fri, 18 Oct 2024 16:22:06 -0700 Subject: [PATCH] kernel/vfs: Don't allow reads/writes past the end of :ofbXX --- kernel/vfs/ofb.asm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/vfs/ofb.asm b/kernel/vfs/ofb.asm index 753a600..ad99844 100644 --- a/kernel/vfs/ofb.asm +++ b/kernel/vfs/ofb.asm @@ -37,8 +37,9 @@ open_stream_ofb: in r0, r0 mov r1, r0 srl r1, 16 - and r1, 0x0000FFFF + and r0, 0x0000FFFF mul r1, r0 + mul r1, 4 mov [r2], r1 ; write file_size add r2, 4 mov [r2], 0 ; write file_reserved_3 @@ -76,7 +77,7 @@ ofb_stream_read: srl r0, 16 and r1, 0x0000FFFF mul r1, r0 - mul r0, 4 + mul r1, 4 pop r0 ; ensure the seek offset is less than the overlay size