Integer overflow: Difference between revisions

Content deleted Content added
Phoenixrod (talk | contribs)
m punctuation
Security ramifications: Closer to the truth.
Line 23:
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 [[LispAda (programming language)|LispAda]] (and [[Adacertain (programmingvariants of languagefunctional languages)|Ada]], provide mechanisms that, if used, result in accidental overflow triggering an exception condition. Many languages do not support such functionality. In [[Python (programming language)|Python]], a number that becomes too large for an integer seamlessly becomes a long.<ref>[http://www.python.org/doc/1.4/ref/ref5.html Python documentation], section 5.1 Arithmetic conversions.</ref> And in Python 3.0, integers and arbitrary sized longs are unified.<ref>[http://www.python.org/dev/peps/pep-0237/ Python Enhancement Proposal 237]</ref>
 
==Techniques for mitigating integer overflow problems==