The software incorrectlychecks a return value from a function, which prevents the software from detecting errors or exceptional conditions.
Time of Introduction
Implementation
Applicable Platforms
Languages
All
Common Consequences
Scope
Effect
Integrity
Other
Technical Impact: Other
The data -- which were produced as a result of an improperly checked
return value of a function -- could be in a bad state.
Likelihood of Exploit
Low
Demonstrative Examples
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
}
Potential Mitigations
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.
Other Notes
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.