Mismatch between data length and size
Data size argument is not computed from actual data length
Description
This defect occurs when you do not check the length argument and data buffer argument of
memory copying functions such as memcpy
, memset
,
or memmove
, to protect against buffer overflows.
Risk
If an attacker can manipulate the data buffer or length argument, the attacker can cause buffer overflow by making the actual data size smaller than the length.
This mismatch in length allows the attacker to copy memory past the data buffer to a new location. If the extra memory contains sensitive information, the attacker can now access that data.
This defect is similar to the SSL Heartbleed bug.
Fix
When copying or manipulating memory, compute the length argument directly from the data so that the sizes match.
Examples
Result Information
Group: Security |
Language: C | C++ |
Default: Off |
Command-Line Syntax: DATA_LENGTH_MISMATCH |
Impact: Medium |
Version History
Introduced in R2015b
See Also
Copy of overlapping memory
| Find defects (-checkers)
Topics
- Interpret Bug Finder Results in Polyspace Desktop User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Results in Polyspace User Interface Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)