According to C99C11, Section 7.1921.3 p6, para. 6,
The address of the
FILE
object used to control a stream may be significant; a copy of aFILE
object need not serve in place of the original.
...
Code Block | ||||
---|---|---|---|---|
| ||||
int main(void) {
FILE my_stdout = *(stdout);
if (fputs("Hello, World!\n", &my_stdout) == EOF) {
/* Handle error */
}
return 0;
}
|
...
Code Block | ||||
---|---|---|---|---|
| ||||
int main(void) {
FILE *my_stdout = stdout;
if (fputs("Hello, World!\n", my_stdout) == EOF) {
/* Handle error */
}
return 0;
}
|
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
FIO38-C | low | probable | medium | P4 | L3 |
Automated Detection
Tool | Version | Checker | Description | section||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Compass/ROSE | Section | Can detect simple violations of this rule section. | |||||||||
| 591 S section | Fully Implemented implemented. |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
...
CERT C++ Secure Coding Standard: FIO38-CPP. Do not use a copy of a FILE object for input and output
ISO/IEC 9899:19992011 Section 7.1921.3, "Files"
ISO/IEC TR 17961 (Draft) Copying a FILE object [filecpy]
Bibliography
...