Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: REM Cost Reform

...

Understanding the difference between text mode and binary mode with file streams is critical when working with functions that operate on them. Setting the file position indicator to end-of-file with fseek() has undefined behavior for a binary stream. In addition, the return value of ftell() for streams opened in text mode is useful only in calls to fseek(), not for determining file sizes or for any other use. As such, fstat() or other platform-equivalent functions should be used to determine the size of a file.

Recommendation

Severity

Likelihood

Remediation Cost

Detectable

Repairable

Priority

Level

FIO19-C

Low

Unlikely

Medium

Yes

Yes

P2

P3

L3

Automated Detection

Tool

Version

Checker

Description

LDRA tool suite
Include Page
LDRA_V
LDRA_V
44 SEnhanced Enforcement

Bibliography

[IEEE Std 1003.1:2013]XSH, System Interfaces, fopen
XSH, System Interfaces, fwrite
[ISO/IEC 9899:2011]Section 7.21.3, "Files"
Section 7.21.9.2, "The fseek Function"
Section 7.21.9.4, "The ftell Function"
[MSDN]"ftell"

...


...