-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Potential integer underflow in format_converter()
when precision < 0
and adjust_precision == true
#18758
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
Comments
It is a fine observation, but not sure this code path is actually reached/used by any platform, especially since the switch to C99 (if SVACE works more like cppcheck rather than analysis during build, then it is less surprising). And seems, if I m reading correctly, this bug had been acknowledged already by @derickr |
How exactly is this undefined behaviour? |
Sorry, you're right — it's not undefined behavior, but it does cause an underflow when a negative |
I think that's the intention. |
Yes, you're right! Thank you! |
Description
Hi,
In the following code, possible
precision
variable value being set to-1
andadjust_precision == true
:php-src/main/snprintf.c
Lines 576 to 586 in 3a14ce1
This can result undefined behavior when
precision
is later cast tosize_t
.php-src/main/snprintf.c
Line 845 in 3a14ce1
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Reporter: Pavel Nekrasov ([email protected]).
Organization: Fobos-NT ([email protected]).
PHP Version
Operating System
Alt p10
The text was updated successfully, but these errors were encountered: