...
Noncompliant Code Example (fscanffscanf()
)
In this noncompliant example, the call to fscanf()
can result in a write outside the character array buf
.
Code Block | ||||
---|---|---|---|---|
| ||||
#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
.
...