500
CWE-197: Numeric Truncation Error
Weakness ID : 197
Structure : Simple
Abstraction : Base
Description
Truncation errors occur when a primitive is cast to a primitive of a smaller size and data is lost in
the conversion.
Extended Description
When a primitive is cast to a smaller primitive, the high order bits of the large value are lost in the
conversion, potentially resulting in an unexpected value that is not equal to the original value. This
value may be required as an index into a buffer, a loop iterator, or simply necessary state data.
In any case, the value cannot be trusted and the system will be in an undefined state. While this
method may be employed viably to isolate the low bits of a value, this usage is rare, and truncation
usually implies that an implementation error has occurred.
Relationships
The table(s) below shows the weaknesses and high level categories that are related to this
weakness. These relationships are defined as ChildOf, ParentOf, MemberOr and give insight to
similar items that may exist at higher and lower levels of abstraction. In addition, relationships such
as PeerOf and CanAlsoBe are defined to show similar weaknesses that may want to be explored.
Relevant to the view "Research Concepts" (CWE-1000)
Nature Type ID Name Page
ChildOf 681 Incorrect Conversion between Numeric Types 1495
CanAlsoBe 192 Integer Coercion Error 482
CanAlsoBe 194 Unexpected Sign Extension 491
CanAlsoBe 195 Signed to Unsigned Conversion Error 494
CanAlsoBe 196 Unsigned to Signed Conversion Error 498
Relevant to the view "CISQ Quality Measures (2020)" (CWE-1305)
Nature Type ID Name Page
ChildOf 681 Incorrect Conversion between Numeric Types 1495
Relevant to the view "CISQ Data Protection Measures" (CWE-1340)
Nature Type ID Name Page
ChildOf 681 Incorrect Conversion between Numeric Types 1495
Applicable Platforms
Language : C (Prevalence = Undetermined)
Language : C++ (Prevalence = Undetermined)
Language : Java (Prevalence = Undetermined)
Language : C# (Prevalence = Undetermined)
Likelihood Of Exploit
Low
Common Consequences
Scope Impact Likelihood
Integrity Modify Memory
The true value of the data is lost and corrupted data is
used.
CWE Version 4.14
CWE-197: Numeric Truncation Error
CWE-197: Numeric Truncation Error