...
| Code Block | ||||
|---|---|---|---|---|
| ||||
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
FILE *out;
FILE *in;
size_t size;
char *ptr;
if (argc != 2) {
/* Handle error */
}
in = fmemopen(argv[1], strlen(argv[1]), "r");
if (in == NULL){
/* Handle error */
}
/* Use in */
out = open_memstream(&ptr, &size);
if (out == NULL){
/* Handle error */
}
/* Use out */
return 0;
} |
Exceptions
POS54-C-EX1: This exception has been removed.
POS54-C-EX2: The exception from ERR33-C. Detect and handle standard library errors (that is ERR33-C-EX1) applies to this rule. See that exception for more information.
...
Failing to detect error conditions can lead to unpredictable results, including abnormal program termination and denial-of-service attacks or, in some situations, could even allow an attacker to run arbitrary code.
Rule | Severity | Likelihood | Detectable | RepairableRemediation Cost | Priority | Level |
|---|---|---|---|---|---|---|
POS54-C | High | Likely | Yes | YesMedium | P18P27 | L1 |
Automated Detection
Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Astrée |
| error-information-unused error-information-unused-computed | Supported | ||||||
| Axivion Bauhaus Suite |
| CertC-POS54 | |||||||
| CodeSonar |
| LANG.FUNCS.IRV LANG.ERRCODE.NOTEST LANG.ERRCODE.NZ | Ignored return value Missing Test of Error Code Non-zero Error Code | ||||||
| Compass/ROSE | Can detect violations of this recommendation when checking for violations of EXP12-C. Do not ignore values returned by functions and EXP34-C. Do not dereference null pointers | ||||||||
| CHECKED_RETURN | Finds inconsistencies in how function call return values are handled. Coverity Prevent cannot discover all violations of this recommendation, so further verification is necessary | |||||||
| Helix QAC |
| C3200 | |||||||
| Klocwork |
| SV.RVT.RETVAL_NOTTESTED | |||||||
| LDRA tool suite |
| 80 D | Partially implemented | ||||||
| Parasoft C/C++test |
| CERT_C-POS54-a | The value returned by a POSIX library function that may return an error should be used | ||||||
| PC-lint Plus |
| 413, 534, 613 | Assistance provided | ||||||
| CERT C: Rule POS54-C | Checks for situations where return value of a sensitive function is not checked (rule fully covered) | |||||||
| RuleChecker |
| error-information-unused | Supported |
...