range check char length
This commit is contained in:
@@ -866,7 +866,8 @@ evaluate_constant:
|
|||||||
jmp .bin_loop
|
jmp .bin_loop
|
||||||
|
|
||||||
.chr:
|
.chr:
|
||||||
; TODO range check rcx
|
cmp rcx, 4 ; ensure char is only 4 bytes long
|
||||||
|
jg .unrecognised
|
||||||
cmp rsi, 1 ; range check
|
cmp rsi, 1 ; range check
|
||||||
je .chr_break
|
je .chr_break
|
||||||
|
|
||||||
@@ -896,7 +897,7 @@ evaluate_constant:
|
|||||||
jmp .chr_break
|
jmp .chr_break
|
||||||
|
|
||||||
.chr_break_for_good:
|
.chr_break_for_good:
|
||||||
mov dl, [rdi]
|
mov dl, [rdi] ; make sure the chr is closed
|
||||||
cmp dl, '"'
|
cmp dl, '"'
|
||||||
jne .unrecognised
|
jne .unrecognised
|
||||||
|
|
||||||
|
|||||||
@@ -377,6 +377,13 @@ test_evaluate_constant:
|
|||||||
cmp rdx, 0x03
|
cmp rdx, 0x03
|
||||||
jne .fail
|
jne .fail
|
||||||
|
|
||||||
|
; oversized char
|
||||||
|
mov rdi, .case1c
|
||||||
|
mov rsi, 7
|
||||||
|
call evaluate_constant
|
||||||
|
cmp rdx, 0xFF
|
||||||
|
jne .fail
|
||||||
|
|
||||||
.pass:
|
.pass:
|
||||||
mov rsi, msg_pass
|
mov rsi, msg_pass
|
||||||
call print
|
call print
|
||||||
@@ -396,6 +403,8 @@ test_evaluate_constant:
|
|||||||
.case3h_solution dq 0x243F6A8885A308D3
|
.case3h_solution dq 0x243F6A8885A308D3
|
||||||
.case0c db '"char"'
|
.case0c db '"char"'
|
||||||
.case0c_solution dq "char"
|
.case0c_solution dq "char"
|
||||||
|
.case1c db '"chars"'
|
||||||
|
.case1c_solution dq "chars"
|
||||||
|
|
||||||
.case0q db "0q31103755242102"
|
.case0q db "0q31103755242102"
|
||||||
.case0q_solution dq 0q31103755242102
|
.case0q_solution dq 0q31103755242102
|
||||||
|
|||||||
Reference in New Issue
Block a user