Description
Truncation errors occur when a primitive is cast to a primitive of a smaller size and data is lost in the conversion.
Potential Impact
How to Fix
Implementation
Ensure that no casts, implicit or explicit, take place that move from a larger size primitive or a smaller size primitive.
Detection Methods
- Fuzzing: Fuzz testing (fuzzing) is a powerful technique for generating large numbers of diverse inputs - either randomly or algorithmically - and dynamically invoking the code with those inputs. Even with rand...
- Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without havin...
Related Weaknesses
References
View on MITRE CWE Database →