Misuse of a FILE object
Use of copy of FILE object
Description
This defect occurs when:
You dereference a pointer to a FILE object, including indirect dereference by using
memcmp()
.You modify an entire FILE object or one of its components through its pointer.
You take the address of FILE object that was not returned from a call to an
fopen
-family function. No defect is raised if a macro defines the pointer as the address of a built-in FILE object, such as#define ptr (&__stdout)
.
Risk
In some implementations, the address of the pointer to a FILE object used to control a stream is significant. A pointer to a copy of a FILE object is interpreted differently than a pointer to the original object, and can potentially result in operations on the wrong stream. Therefore, the use of a copy of a FILE object can cause the software to stop responding, which an attacker might exploit in denial-of-service attacks.
Fix
Do not make a copy of a FILE object. Do not use the address of a FILE object that was
not returned from a successful call to an fopen
-family function.
Examples
Result Information
Group: Programming |
Language: C | C++ |
Default: On for handwritten code, off for generated code |
Command-Line Syntax:
FILE_OBJECT_MISUSE
|
Impact: Low |
Version History
Introduced in R2017b
See Also
Topics
- Interpret Bug Finder Results in Polyspace Desktop User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Results in Polyspace User Interface Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)