Use of copy of FILE object
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).
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.
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.
| Group: Programming |
| Language: C | C++ |
| Default: On for handwritten code, off for generated code |
Command-Line Syntax:
FILE_OBJECT_MISUSE
|
| Impact: Low |