Versions Compared

Key

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

...

Code Block
bgColor#ccccff
langc
#include <stdio.h>
 
void do_stuff(FILE *logfile) {
  /* Write logs pertaining to do_stuff() */
  fprintf(logfile, "do_stuff\n");
}

int main(void) {
  FILE *logfile = fopen("log", "a");
  if (logfile == NULL) {
    /* Handle error */
  }

  /* Write logs pertaining to main() */
  fprintf(logfile, "main\n");

  do_stuff(logfile);
 
  if (fclose(logfile) == EOF) {
    /* Handle error */
  }
  return 0;
}

Automated Detection

...

Tool

...

Version

...

Checker

...

Description

...

LDRA tool suite

...

75 D

...

Fully implemented

Risk Assessment

Simultaneously opening a file multiple times can result in unexpected errors and nonportable behavior.

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

FIO31-C

Medium

Probable

High

P4

L3

Automated Detection

Tool

Version

Checker

Description

LDRA tool suite

Include Page
LDRA_V
LDRA_V

75 D

Fully implemented

Related Vulnerabilities

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

...