printf: Prevent special characters not being processed if it was proceeded by a percentage sign (ie '%\n')

This commit is contained in:
2025-07-20 12:35:13 +02:00
parent b0e9193b0a
commit 6bc6000454
2 changed files with 29 additions and 12 deletions

View File

@@ -295,6 +295,8 @@ printf:
;--- Invalid ---;
.invalidReplacement:
cmp byte [rdi + 1], '\'
je .invalidReplacement_specialChar; '%\n' would become "'%','\','n'" instead of "'%',EOS" when inserting full invalid specifier.
mov r9w, word [rdi]
mov [printfBuff+r10], r9w
add rdi, 2
@@ -302,6 +304,14 @@ printf:
add r11, 2
inc r14
jmp .process
.invalidReplacement_specialChar:
mov r9b, byte [rdi]
mov [printfBuff+r10], r9b
inc rdi
inc r10
inc r11
inc r14
jmp .process
;--- '%%' ---;
.rep_pct: