Returned value of a sensitive function not checked
Sensitive functions called without checking for unexpected return values and errors
Description
This defect occurs when you call sensitive standard functions that return information about possible errors and you do one of the following:
Ignore the return value.
You simply do not assign the return value to a variable, or explicitly cast the return value to
void
.Use an output from the function (return value or argument passed by reference) without testing the return value for errors.
The checker considers a function as sensitive if the function call is prone to failure because of reasons such as:
Exhausted system resources (for example, when allocating resources).
Changed privileges or permissions.
Tainted sources when reading, writing, or converting data from external sources.
Unsupported features despite an existing API.
The checker only considers functions where the return value indicates if the function completed without errors.
Some of these functions can perform critical tasks such as:
Set privileges (for example,
setuid
)Create a jail (for example,
chroot
)Create a process (for example,
fork
)Create a thread (for example,
pthread_create
)Lock or unlock mutex (for example,
pthread_mutex_lock
)Lock or unlock memory segments (for example,
mlock
)
Risk
If you do not check the return value of functions that perform sensitive tasks and indicate error information through their return values, your program can behave unexpectedly. Errors from these functions can propagate throughout the program causing incorrect output, security vulnerabilities, and possibly system failures.
Fix
Before continuing with the program, test the return value of critical sensitive functions.
For sensitive functions that are not critical, you can explicitly ignore a return value by
casting the function to void
. Polyspace® does not raise this defect for sensitive functions cast to void. This
resolution is not accepted for critical sensitive functions
because they perform more vulnerable tasks.
Examples
Result Information
Group: Security |
Language: C | C++ |
Default: Off |
Command-Line Syntax: RETURN_NOT_CHECKED |
Impact: High |
Version History
Introduced in R2016bSee Also
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)