-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Integer-overflow (OSS-Fuzz issue 267) #389
Comments
Some notes:
|
This is a false-positive; in the context of the code this is not a problem even though static_cast overflows. The value is 2^63; all math checks out. |
I think the point is that whatever happens after the overflow is implementation-defined. According to C++11 standard section 4.7 (Integral conversions) point 3:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf |
There is a discussion on the number |
I think this is a valid bug: -INT64_MIN is not defined (=INT64_MAX + 1). The result of this operation could depend on compiler, platform and compilation flags. |
One naive idea: if (value == max) // edit: before I had 9223372036854775808 instead of max
result.m_value.number_integer = INT64_MIN;
else
result.m_value.number_integer = -static_cast<number_integer_t>(value); |
With 79fa8b2 the warning is gone and all tests still succeed. If Travis and AppVeyor succeed, I shall trigger a re-test at OSS-Fuzz. |
It will re-test automatically once new fuzzer is built and used by cluster-fuzz (~1 day). Let's give it a chance to work automatically. |
@mikea Thanks for the hint! And thanks for taking care about this! |
I was a bit surprised that the standard would leave this detail implementation-defined and did some googling. Turns out that is so in order to facilitate compatibility with hardware that employs one's-complement representation of integral types, just in case someone decides to implement a c++11 compiler for a UNIVAC-1100. |
@TurpentineDistillery I agree that the reason it is undefined is very outdated. The unspecified behaviour is still in the standard and compilers might take opportunities related to it and such bugs are worth fixing. Take a look at Chandler's talk from last CppCon where he touches on similar issues: https://www.youtube.com/watch?v=yG1OZ69H_-o |
The error has been reported as fixed:
Thanks for the cooperation! |
oh cool, you do fuzz testing! do you know this one? it's fantastic: http://lcamtuf.coredump.cx/afl/ |
Yes, there is a makefile target |
The library is continuously fuzz tested by Google's OSS-Fuzz. Today, an error was reported:
The linked report contains this input file: fuzz-2-json_parse_fuzzer.zip
Furthermore, this error message describes the error.
This is the line in question:
The text was updated successfully, but these errors were encountered: