...
Many implementations of the stdio
package adjust their behavior slightly if stdout
is a terminal. To make the determination, these implementations perform some operation that fails (with ENOTTY
) if stdout
is not a terminal. Although the output operation goes on to complete successfully, errno
still contains ENOTTY
. This behavior can be mildly confusing, but it is not strictly incorrect because it is only meaningful for a program to inspect the contents of errno
only after an error has been reported. More precisely, errno
is meaningful only meaningful after a library function that sets errno
on error has returned an error code.
...
Checking errno
after multiple calls to library functions can lead to spurious error reporting, possibly resulting in incorrect program operation.
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
ERR01-C |
Low |
Probable |
Low | P6 | L2 |
Automated Detection
Tool | Version | Checker | Description | ||||
---|---|---|---|---|---|---|---|
|
CC2.ERR01 | Fully implemented | ||||||||
LDRA tool suite |
| 44 S | Enhanced Enforcement | ||||||
Parasoft C/C++test |
| CERT_C-ERR01-a | The error indicator 'errno' shall not be used |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
...
...
...
ISO/IEC 9899:2011 Section 6.3.1.1, "Boolean, characters, and integers," Section 7.1.4, "Use of library functions," and Section 7.21.10.3, "The ferror
function"
...
Bibliography
[Horton 1990] | Section 14, p. 254 |
[Koenig 1989] | Section 5.4, p. 73 |
...