Incorrect Check of Function Return Value |
Weakness ID: 253 (Weakness Base) | Status: Incomplete |
Description Summary
The software incorrectly checks a return value from a function, which prevents the software from detecting errors or exceptional conditions.
Scope | Effect |
---|---|
Integrity | The data -- which were produced as a result of an improperly checked return value of a function -- could be in a bad state. |
Example 1
(Bad Code)
Example Languages: C and C++
tmp = malloc(sizeof(int) * 4);
if (tmp < 0 ) {
perror("Failure");
//should have checked if the call returned 0
}
Requirements specification: Use a language or compiler that uses exceptions and requires the catching of those exceptions. |
Phase: Implementation Properly check all functions which return a value. |
Phase: Implementation When designing any function make sure you return a value or throw an exception in case of an error. |
Important and common functions will return some value about the success of its actions. This will alert the program whether or not to handle any errors caused by that function. |
Nature | Type | ID | Name | View(s) this relationship pertains to |
---|---|---|---|---|
ChildOf | Weakness Class | 227 | Failure to Fulfill API Contract ('API Abuse') | Development Concepts (primary)699 |
ChildOf | Category | 389 | Error Conditions, Return Values, Status Codes | Development Concepts699 |
ChildOf | Weakness Class | 573 | Failure to Follow Specification | Research Concepts (primary)1000 |
ChildOf | Weakness Class | 754 | Improper Check for Unusual or Exceptional Conditions | Research Concepts1000 |
Mapped Taxonomy Name | Node ID | Fit | Mapped Node Name |
---|---|---|---|
CLASP | Misinterpreted function return value |
Submissions | ||||
---|---|---|---|---|
Submission Date | Submitter | Organization | Source | |
CLASP | Externally Mined | |||
Modifications | ||||
Modification Date | Modifier | Organization | Source | |
2008-09-08 | CWE Content Team | MITRE | Internal | |
updated Common Consequences, Relationships, Other Notes, Taxonomy Mappings | ||||
2008-11-24 | CWE Content Team | MITRE | Internal | |
updated Demonstrative Examples | ||||
2009-03-10 | CWE Content Team | MITRE | Internal | |
updated Description, Name, Relationships | ||||
Previous Entry Names | ||||
Change Date | Previous Entry Name | |||
2009-03-10 | Misinterpreted Function Return Value | |||