...
The following sections examine specific operations that are susceptible to unsigned integer wrap. When operating on integer types with less precision than int
, integer promotions are applied. The usual arithmetic conversions may also be applied to (implicitly) convert operands to equivalent types before arithmetic operations are performed. Programmers should understand integer conversion rules before trying to implement secure arithmetic operations . (See see INT02-C. Understand integer conversion rules).)
Integer values must not be allowed to wrap, especially if they are used in any of the following ways:
...
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
CodeSonar |
| ALLOC.SIZE.ADDOFLOW | Addition Overflow overflow of Allocation Sizeallocation size | ||||||
|
| Can detect violations of this rule by ensuring that operations are checked for overflow before being performed. Be mindful of exception INT30-EX2 because it excuses many operations from requiring validation, including all the operations that would validate a potentially dangerous operation. For instance, adding two | |||||||
Coverity | 6.5 | INTEGER_OVERFLOW | Implemented | ||||||
5.0 |
| Can detect violations of this rule with the CERT C Rule Pack | |||||||
LDRA tool suite |
| 493 S, 494 S | Partially implemented | ||||||
PRQA QA-C |
| 2910 (C) | Partially implemented |
...
...
[Bailey 2014] | Raising Lazarus - The 20 Year Old Bug that Went to Mars |
[Dowd 2006] | Chapter 6, "C Language Issues" ("Arithmetic Boundary Conditions," pp. 211–223) |
[ISO/IEC 9899:2011] | Subclause 6.2.5, "Types" |
[Seacord 2013b] | Chapter 5, "Integer Security" |
[Viega 2005] | Section 5.2.7, "Integer Overflow" |
[VU#551436] | |
[Warren 2002] | Chapter 2, "Basics" |
[Wojtczuk 2008] | |
[xorl 2009] | "CVE-2009-1385: Linux Kernel E1000 Integer Underflow" |
...