-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
_vsnprintf reads past the format parameter value #140
Comments
Thanks for your effort filing this. I will try to look into it within the next few days. If I can perhaps even by tomorrow, but no guarantees. |
First - I can verify that this is not a bug. The standard states that only with a valid conversion specifier is the behavior defined. With UB, it is legitimate for |
…hen a format specifier does not end before the string does.
Please try out the tip of branch fix-140, and let me know what you think. |
Compiling like this: gcc -DPRINTF_CHECK_FOR_NUL_IN_FORMAT_SPECIFIER=1 -fsanitize=address -o tst -I src main.c src/printf/printf.c Works safely:
Let's hope users define PS a diff with the master seems to contain more changes than necessary, is that your intention? |
If you use CMake to build the program, it'll default to ON. In fact, I can make it default to on even without CMake... |
…hen a format specifier does not end before the string does.
So, my own tests weren't passing; I've amended the commit. |
…hen a format specifier does not end before the string does.
@aptly-io : Are you ok with the changes I've made on this branch? If so, I'll merge them into develop |
@eyalroz Thank you. I will try it out during the weekend. I had this initial thought. I can find myself in @ledvinap argument that it's cleaner to validate So for instance I'm pondering when you check for 0 after returning from |
That's because after the ... and actually, checking after |
…hen a format specifier does not end before the string does.
…hen a format specifier does not end before the string does.
Ok, merged this change into the develop branch. |
…hen a format specifier does not end before the string does.
@eyalroz Thank you for the fix: Note I noticed that
On your earlier reply:
It proves my point made earlier that |
Fixed.
Fair enough. |
…hen a format specifier does not end before the string does.
This code snippet illustrates the issue (the issue does not manifest when using libc's printf):
(it can likely be abused by a hacker for malicious purposes)
It originated here mpaland#139
Compile like this:
The output:
The text was updated successfully, but these errors were encountered: