Versions Compared

Key

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

...

Compliant Solution (POSIX) (open only once)

A simpler solution is to simply not reopen the file. In this code example, the file is opened once for both writing and reading. Once writing is complete, the fseek() function resets the file pointer to the beginning of the file, and its contents are read back (see FIO07-C. Prefer fseek() to rewind()).

...

Many file-related vulnerabilities are exploited to cause a program to access an unintended file. Proper file identification of a file is necessary to prevent exploitation.

...