Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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 a FILE object need not serve in place of the original.

...

Code Block
bgColor#FFCCCC
langc

int main(void) {
  FILE my_stdout = *(stdout);
  if (fputs("Hello, World!\n", &my_stdout) == EOF) {
    /* Handle error */
  }
  return 0;
}

...

Code Block
bgColor#ccccff
langc

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

sectioncan

Can detect simple violations of this rule

section

.

ToolVersionCheckerDescription
Compass/ROSE  
Section

LDRA tool suite

Include Page
LDRA_V
LDRA_V
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

...