Memory allocation with tainted size
Size argument to memory function is from an unsecure source
Description
This defect occurs when a memory allocation function, such as calloc
or
malloc
, uses a size argument from an unsecure
source.
Risk
Uncontrolled memory allocation can cause your program to request too much system memory. This consequence can lead to a crash due to an out-of-memory condition, or assigning too many resources.
Fix
Before allocating memory, check the value of your arguments to check that they do not exceed the bounds.
Extend Checker
By default, Polyspace® assumes that data from external sources are tainted.
See Sources of Tainting in a Polyspace Analysis. To consider any data that does not originate in the current
scope of Polyspace analysis as tainted, use the command line option
-consider-analysis-perimeter-as-trust-boundary
.
Examples
Result Information
Group: Tainted Data |
Language: C | C++ |
Default: Off |
Command-Line Syntax: TAINTED_MEMORY_ALLOC_SIZE |
Impact: Medium |
Version History
Introduced in R2015b
See Also
Unprotected dynamic memory allocation
| Find defects (-checkers)
| -consider-analysis-perimeter-as-trust-boundary
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)
- Sources of Tainting in a Polyspace Analysis
- Modify Default Behavior of Bug Finder Checkers