From 50ea28fc7e962a1f16c056a5004351b1d93ddd2e Mon Sep 17 00:00:00 2001 From: Ry Date: Thu, 13 Jul 2023 21:21:16 -0700 Subject: [PATCH] kernel/vfs: Only allow :ofb0 - :ofb31 --- kernel/vfs/ofb.asm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/vfs/ofb.asm b/kernel/vfs/ofb.asm index 90b1531..d872f51 100644 --- a/kernel/vfs/ofb.asm +++ b/kernel/vfs/ofb.asm @@ -7,7 +7,7 @@ overlay_vfs_stream_name: data.strz "ofb" ; r0: pointer to null-terminated string "ofbXX" where XX is 0 - 31 ; r2: file struct: pointer to a blank file struct (stream) ; outputs: -; r0: non-zero +; r0: non-zero if valid overlay open_stream_ofb: push r1 push r2 @@ -15,6 +15,11 @@ open_stream_ofb: add r0, 3 mov r1, 10 call string_to_int + cmp r0, 31 + ifgt mov r0, 0 + ifgt pop r2 + ifgt pop r1 + ifgt ret mov.8 [r2], r0 ; write file_overlay inc r2