WRITE ME ALEX
This non-compliant code example calls puts() and fails to check whether a write error occurs.
puts("foo");
|
This compliant solution checks to make sure no output error occurred (see FIO04-A. Detect and handle input and output errors).
if(puts("foo") == EOF) {
/* Handle Error */
}
|
EXP12-EX1: If a function cannot fail or if the return value is inconsequential, such as for functions called because of their side effects, the function should be explicitly cast to void to signify programmer intent
(void) strcpy(dst, src); |
Failure to handle error codes or other values returned by functions can lead to incorrect program flow and violations of data integrity.
Recommendation |
Severity |
Likelihood |
Remediation Cost |
Priority |
Level |
|---|---|---|---|---|---|
EXP12-A |
medium |
unlikely |
medium |
P4 |
L3 |
Splint Version 3.1.1 can detect violations of this rule.
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
\[[ISO/IEC 9899:1999|AA. C References#ISO/IEC 9899-1999]\] |
EXP11-A. Do not apply operators expecting one type to data of an incompatible type 03. Expressions (EXP) EXP30-C. Do not depend on order of evaluation between sequence points