Versions Compared

Key

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

Wiki Markup
If the C99 {{fgets()}} function fails, the contents of the array it was writing to are [indeterminate| BB. Definitions#indeterminate value] \[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\]. (seeSee also [undefined behavior 161| CC. Undefined Behavior#ub_161] of Annex J.). Consequently, it is necessary to reset the string to a known value to avoid possible errors on subsequent string manipulation functions.

...

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

Other Languages

Related Guidelines

CERT This rule appears in the C++ Secure Coding Standard as : FIO40-CPP. Reset strings on fgets() failure.

Bibliography

unmigrated-wiki-markup

\[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] Section 7.19.7.2, "The {{fgets}} function" and Section 7.24.3.2, "the {{fgetws}} function"

Bibliography

...

      09. Input Output (FIO)      FIO41-C. Do not call getc() or putc() with stream arguments that have side effects