Re:Cap'n'Proto remote vuln: pointer overflow check optimized...
by banachtarski on Friday April 21, 2017 @12:12PM
(#14166828)
There is no undefined behavior here? Unsigned overflow wraps around and this is correct. Always has been in C++ for as long as I can remember.
[ Parent
| on HN ]
Re:Cap'n'Proto remote vuln: pointer overflow check optimized...
by kentonv on Friday April 21, 2017 @12:18PM
(#14166898)
Unsigned overflow wraps around, but signed and pointer overflow are UB. In this case, the code was depending on pointer overflow wrapping around.
Re:Cap'n'Proto remote vuln: pointer overflow check optimized...
by detaro on Friday April 21, 2017 @12:17PM
(#14166890)
I don't think pointer arithmetic is defined to behave as unsigned. Unsigned is the exception in that it's overflow behavior is defined.
Re:Cap'n'Proto remote vuln: pointer overflow check optimized...
by banachtarski on Friday April 21, 2017 @03:31PM
(#14168631)
edit: oh gosh I totally misread something
> Since farPointer.offset is an unsigned number, the compiler is able to conclude that target < segmentStart always evaluates false. Thus, the compiler removes this part of the check. Unfortunately, in the case of overflow, this is exactly the part of the check that we need.
This certainly seems like a compiler bug!