printf: incorrectly printing specifier if padding length (>1 chars) defined with invalid specifier #5

Open
opened 2025-07-24 22:29:41 +02:00 by Kwarde · 0 comments
Owner

Take this example:
"He%0llo there" would be printed as He%0llo there, as expected.
However, "He%00llo there" would be printed as He00llo there.
Longer padding lengths would print the same.
This makes sense because if padding length is 0 RDI is decreased by one (and when reaching invalid specifier, if padding length != 0 it is decreased by one). Then word [rdi] is written to buffer.

This is a bit complicated because now I'll also have to store the string length of given padding, and then set rdi pointer accordingly.
Low prio. Just keeping this issue here in case I ever feel like fixing it.
This is not a prod project anyway, and it's simple; just use the function correctly (which I do). This is just an edge case that might be fix in the future (it's not that complicated to do, it's just a hazzle -- and again since it's not a production thing, low prio, not feeling like fixing it rn)

Take this example: `"He%0llo there"` would be printed as `He%0llo there`, as expected. However, `"He%00llo there"` would be printed as `He00llo there`. Longer padding lengths would print the same. This makes sense because if padding length is 0 RDI is decreased by one (and when reaching invalid specifier, if padding length != 0 it is decreased by one). Then `word [rdi]` is written to buffer. This is a bit complicated because now I'll also have to store the string length of given padding, and then set rdi pointer accordingly. Low prio. Just keeping this issue here in case I ever feel like fixing it. This is not a prod project anyway, and it's simple; just use the function correctly (which I do). This is just an edge case that might be fix in the future (it's not that complicated to do, it's just a hazzle -- and again since it's not a production thing, low prio, not feeling like fixing it rn)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Kwarde/klibc#5
No description provided.