Integer overflow bug in windows
Marco Leise
Marco.Leise at gmx.de
Thu Nov 10 00:49:16 PST 2011
Am 10.11.2011, 00:07 Uhr, schrieb Alex Rønne Petersen
<xtzgzorex at gmail.com>:
> On 09-11-2011 23:49, bearophile wrote:
>> Kagamin:
>>
>>> http://blogs.technet.com/b/srd/archive/2011/11/08/assessing-the-exploitability-of-ms11-083.aspx
>>
>> I'd like a runtime error when an integral overflows (unsigned numbers
>> too, the C99 Standard is not a religion book for me), unless where
>> asked otherwise.
>>
>> Bye,
>> bearophile
>
> If anything, we should do it like C#: have checked/unchecked arithmetic
> blocks.
>
> - Alex
I know that the article was meant to start this discussion, but no checked
arithmetic could have found this bug while debugging. And if it the check
is kept even in release mode - which is untypical for asserts - the
question is, if an exception or termination of the program would have been
handled gracefully.
On the other hand I wouldn't mind checked arithmetic, especially since
there are assembly instructions like JO. Could this also be used to
execute a different branch when an overflow occurs? I mean: Would some
code become faster and cleaner? I am so used to not having any checking
that I cannot remember any such cases from the top of my head.
In any case blocks are the way to go, because the overflow flag is
manipulated by too many instructions as to just write "if (overflow())
{...}" after a statement. I don't know if we always want an Exception as
in C# though, if people find it useful for general code flow.
More information about the Digitalmars-d
mailing list