...
To correct this error, ensure the pointer returned by malloc()
is not null. This also ensures compliance with guideline MEM32-C. Detect and handle memory allocation errors.
...
Wiki Markup |
---|
Dereferencing a null pointer results in undefined behavior, typically abnormal program termination. In some situations, however, dereferencing a null pointer can lead to the execution of arbitrary code \[[Jack 072007|AA. Bibliography#Jack 07], [van Sprundel 062006|AA. Bibliography#van Sprundel 06]\]. The indicated severity is for this more severe case; on platforms where it is not possible to exploit a null pointer dereference to execute arbitrary code, the actual severity is low. |
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
EXP34-C | high | likely | medium | P18 | L1 |
Automated Detection
The LDRA tool suite Version 7.6.0 can detect violations of this rule.
Fortify SCA Version 5.0 can detect violations of this rule.
Splint Version 3.1.1 can detect violations of this rule.
...
Tool | Version | Checker | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
| ||||||||
|
|
|
| ||||||||
|
|
|
| ||||||||
|
|
|
|
...
|
...
|
|
| |||||||||||||
|
|
|
| ||||||||||||
|
|
|
| ||||||||||||
|
|
|
| ||||||||||||
|
|
|
|
Coverity Prevent cannot discover all violations of this rule, so further verification is necessary.
Klocwork can detect violations of this rule with the NPD.* and RNPD.* checkers. See Klocwork Cross Reference
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Other Languages
This rule appears in the C++ Secure Coding Standard as : EXP34-CPP. Ensure a null pointer is not dereferenced.
...
Wiki Markup |
---|
\[[Goodin 2009|AA. Bibliography#Goodin 2009]\] \[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] Section 6.3.2.3, "Pointers" \[[ISO/IEC PDTR 24772|AA. Bibliography#ISO/IEC PDTR 24772]\] "HFC Pointer casting and pointer type changes" and "XYH Null Pointer Dereference" \[[Jack 072007|AA. Bibliography#Jack 07]\] \[[Liu 2009|AA. Bibliography#Liu 2009]\] \[[MITRE 072007|AA. Bibliography#MITRE 07]\] [CWE ID 476|http://cwe.mitre.org/data/definitions/476.html], "NULL Pointer Dereference" \[[van Sprundel 062006|AA. Bibliography#van Sprundel 06]\] \[[Viega 052005|AA. Bibliography#Viega 05]\] Section 5.2.18, "Null-pointer dereference" |
...