Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Fixing formatting

...

Noncompliant Code Example (fscanffscanf())

In this noncompliant example, the call to fscanf() can result in a write outside the character array buf.

Code Block
bgColor#ffcccc
langc
#include <stdio.h>
 
enum { BUF_LENGTH = 1024 };
 
void get_data(void) {
  char buf[BUF_LENGTH];
  fscanf(stdin, "%s", buf); */
  /* rest of function
}

Compliant Solution (fscanffscanf())

In this compliant solution, the call to fscanf() is constrained not to overflow buf.

...