Integer overflow: Difference between revisions

Content deleted Content added
Bilbo1507 (talk | contribs)
Security ramifications: Nearly all languages have bigint capabilities, and this page isn't a Python campaign. Cool it, and explain both points of view. :)
rv: Rather rosy view of big integer support
Line 19:
In some situations a program may make the assumption that a variable always contains a positive value. If the variable has a signed integer type an overflow can cause its value to wrap and become negative, violating the assumption contained in the program and perhaps leading to unintended behavior. Similarly, subtracting from a small unsigned value may cause it to wrap to a large positive value which may also be an unexpected behavior. Multiplying or adding two integers may result in a value that is non-negative, but unexpectedly small. If this number is used as the number of bytes to allocate for a buffer, the buffer will be allocated unexpectedly small, leading to a potential buffer overflow.
 
Some languages, such as [[Lisp (programming language)|Lisp]] and [[Ada (programming language)|Ada]], provide mechanisms that, if used, result in arithmeticaccidental overflowsoverflow triggering an exception condition. OtherMany languages, do not support such asfunctionality. In [[Python (programming language)|Python]], anda (withnumber "usethat bigint")becomes [[Perl]],too automaticallylarge allocatefor morean memoryinteger when a numberseamlessly becomes tooa largelong.<ref>[http://www.python.org/doc/1.4/ref/ref5.html Python documentation], section 5.1 Arithmetic conversions.</ref> Nearly all languages support [[Arbitrary-precision arithmetic]]And in somePython fashion3.0, but with wildly varying degrees of convenience. C's implementaiton is an example of a very inconvenient one; the programmer must use special data-typesintegers and callarbitrary functionssized forlongs everyare operation, but as usual, C's approach also quite efficientunified. Variable<ref>[http://www.python.org/dev/peps/pep-precision0237/ arithmeticPython operationsEnhancement alwaysProposal imply an efficiency cost because it requires more CPU instructions.237]</ref>
 
==Techniques for mitigating integer overflow problems==