
Conversions can occur explicitly as the result of a cast or implicitly as required by an operation. While conversions are generally required for the correct execution of a program, they can also lead to lost or misinterpreted data. Conversion of an operand value to a compatible type causes no change to the value or the representation [[ISO/IEC 9899-1999]].
The C99 standard rules define how C compilers handle conversions. These rules include integer promotions, integer conversion rank, and the usual arithmetic conversions.
Risk Assessment
Misunderstanding integer conversion rules can lead to errors, which in turn can lead to exploitable vulnerabilities.
Recommendation |
Severity |
Likelihood |
Remediation Cost |
Priority |
Level |
---|---|---|---|---|---|
INT02-A |
2 (medium) |
2 (probable) |
2 (medium) |
P8 |
L2 |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
References
[[Dowd 06]] Chapter 6, "C Language Issues" (Type Conversions 223-270)
[[ISO/IEC 9899-1999]] Section 6.3, "Conversions"
[[ISO/IEC DTR 24772-2007]] Language Vulnerability "XYE Numeric Conversion Errors"
[[MITRE 07]] CWE ID 192, "Integer Coercion Error"; CWE ID 197
, "Numeric Truncation Error"
[[Seacord 05]] Chapter 5, "Integers"
INT01-A. Use size_t for all integer values representing the size of an object 04. Integers (INT) INT03-A. Use a secure integer library