
...
Providing invalid size arguments to memory allocation functions can lead to buffer overflows and the execution of arbitrary code with the permissions of the vulnerable process.
Rule | Severity | Likelihood | Detectable | RepairableRemediation Cost | Priority | Level |
---|---|---|---|---|---|---|
MEM35-C | High | Probable | No | HighNo | P6 | L2 |
Automated Detection
Tool | Version | Checker | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Astrée |
| malloc-size-insufficient | Partially checked Besides direct rule violations, all undefined behaviour resulting from invalid memory accesses is reported by Astrée. | ||||||||||||||||
Axivion Bauhaus Suite |
| CertC-MEM35 | |||||||||||||||||
CodeSonar |
| ALLOC.SIZE.ADDOFLOW | Addition overflow of allocation size | ||||||||||||||||
Compass/ROSE | Could check violations of this rule by examining the size expression to
| ||||||||||||||||||
| BAD_ALLOC_STRLEN SIZECHECK (deprecated) | Partially implemented Can find instances where string length is miscalculated (length calculated may be one less than intended) for memory allocation purposes. Coverity Prevent cannot discover all violations of this rule, so further verification is necessary Finds memory allocations that are assigned to a pointer that reference objects larger than the allocated block | |||||||||||||||||
Cppcheck Premium |
| premium-cert-mem35-c | |||||||||||||||||
Helix QAC |
| C0696, C0701, C1069, C1071, C1073, C2840 | , C2841, C2842, C2843, C2935, C2936, C2937, C2938C++2840, C++2841, C++2842, C++2843, C++2935, C++2936, C++2937, C++2938DF2840, DF2841, DF2842, DF2843, DF2935, DF2936, DF2937, DF2938 | ||||||||||||||||
Klocwork |
| INCORRECT.ALLOC_SIZE | |||||||||||||||||
LDRA tool suite |
| 400 S, 487 S, 115 D | Enhanced enforcement | ||||||||||||||||
Splint | 3.1.1 | ||||||||||||||||||
Parasoft C/C++test |
| CERT_C-MEM35-a | Do not use sizeof operator on pointer type to specify the size of the memory to be allocated via 'malloc', 'calloc' or 'realloc' function | ||||||||||||||||
PC-lint Plus |
| 433, 826 | Partially supported | ||||||||||||||||
Polyspace Bug Finder |
| Checks for:
Rule | fully covered.PRQA QA-C | ||||||||||||||||
Include Page | PRQA QA-C_v | PRQA QA-C_v | 0696, 0701, 1069, 1071, 1073, 2840, 2841, 2842, 2843, 2935, 2936, 2937, 2938 | PRQA QA-C++ | |||||||||||||||
Include Page | cplusplus:PRQA QA-C++_V | cplusplus:PRQA QA-C++_V | 2840, 2841, 2842, 2843, 2935, 2936, 2937, 2938partially covered. | ||||||||||||||||
PVS-Studio |
| V531, V635, V781 | |||||||||||||||||
RuleChecker |
| malloc-size-insufficient | Partially checked | ||||||||||||||||
TrustInSoft Analyzer |
| mem_access | Exhaustively detects undefined behavior (see one compliant and one non-compliant example). |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
...