kernel/vfs: Only allow :ofb0 - :ofb31

This commit is contained in:
Ry 2023-07-13 21:21:16 -07:00
parent 0059493bb2
commit 50ea28fc7e

View File

@ -7,7 +7,7 @@ overlay_vfs_stream_name: data.strz "ofb"
; r0: pointer to null-terminated string "ofbXX" where XX is 0 - 31 ; r0: pointer to null-terminated string "ofbXX" where XX is 0 - 31
; r2: file struct: pointer to a blank file struct (stream) ; r2: file struct: pointer to a blank file struct (stream)
; outputs: ; outputs:
; r0: non-zero ; r0: non-zero if valid overlay
open_stream_ofb: open_stream_ofb:
push r1 push r1
push r2 push r2
@ -15,6 +15,11 @@ open_stream_ofb:
add r0, 3 add r0, 3
mov r1, 10 mov r1, 10
call string_to_int 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 mov.8 [r2], r0 ; write file_overlay
inc r2 inc r2