Optimization-unstable code
Optimization-unstable code
Posted Dec 5, 2013 8:35 UTC (Thu) by jezuch (subscriber, #52988)Parent article: Optimization-unstable code
> char *buf = ...;
> unsigned int len = ...;
>
> if (buf + len < buf) /* overflow check */
> ...
> unsigned int len = ...;
>
> if (buf + len < buf) /* overflow check */
> ...
> On some architectures, according to the paper, that's no great loss as the test doesn't work. But on other architectures, it does protect against a too large value of len.
My take on this is: if you invent TRICKSY code like this, it's your damn fault if it breaks.
> I think the only answer to those lines is to advise you to not use any programs written in C.
Haha only serious ;)