Integer overflow: Difference between revisions

Content deleted Content added
See also: trim list. see also sections are not intended to be a free-association grab bag see MOS:ALSO
m wikilink buffer overflow
Line 26:
 
{{anchor|Security ramifications}}
Such wraparound may cause security detriments—if an overflowed value is used as the number of bytes to allocate for a buffer, the buffer will be allocated unexpectedly small, potentially leading to a [[buffer overflow]] which, depending on the use of the buffer, might in turn cause arbitrary code execution.
 
If the variable has a [[Signed number representations|signed integer]] type, a program may make the assumption that a variable always contains a positive value. An integer overflow can cause the value to wrap and become negative, which violates the program's assumption and may lead to unexpected behavior (for example, 8-bit integer addition of 127 + 1 results in −128, a two's complement of 128). (A solution for this particular problem is to use unsigned integer types for values that a program expects and assumes will never be negative.)