According to the C Standard, 7.2123.3, paragraph 6 [ISO/IEC 9899:20112024],
The address of the
FILEobject used to control a stream may be significant; a copy of aFILEobject need is not required to serve in place of the original.
...
Using a copy of a FILE object in place of the original may result in a crash, which can be used in a denial-of-service attack.
Rule | Severity | Likelihood | Detectable | RepairableRemediation Cost | Priority | Level |
|---|---|---|---|---|---|---|
FIO38-C | Low | Probable | Yes | MediumNo | P4 | L3 |
Automated Detection
| Tool | Version | Checker | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Astrée |
| file-dereference | Partially checked | ||||||||||||||||
| Axivion Bauhaus Suite |
| CertC-FIO38 | Fully implemented | ||||||||||||||||
| Clang |
| misc-non-copyable-objects | Checked with clang-tidy | ||||||||||||||||
| Compass/ROSE | Can detect simple violations of this rule | ||||||||||||||||||
| Coverity |
| MISRA C 2012 Rule 22.5 | Partially implemented | ||||||||||||||||
| Cppcheck Premium |
| premium-cert-fio38-c | |||||||||||||||||
| Helix QAC |
| C1485, C5028 C++3113, C++3114 | |||||||||||||||||
| KlocworkLDRA tool suite |
| 591 S | Fully implemented | RuleChecker | |||||||||||||||
| Include Page | RuleChecker_V | RuleChecker_V | file-dereference | MISRA.FILE_PTR.DEREF.2012 | |||||||||||||||
| LDRA tool suite |
| 591 S | Fully implemented | Partially checked||||||||||||||||
| Parasoft C/C++test |
| CERT_C-FIO38-a | A pointer to a FILE object shall not be dereferenced | ||||||||||||||||
| PC-lint Plus |
| 9047 | Partially supported: reports when a FILE pointer is dereferenced | ||||||||||||||||
| Misuse CERT C: Rule FIO38-C | Checks for misuse of a FILE object | Use of copy of FILE object | PRQA QA-C++ | |||||||||||||||
| Include Page | cplusplus:PRQA QA-C++_V | cplusplus:PRQA QA-C++_V | (rule fully covered) | ||||||||||||||||
| RuleChecker |
| file-dereference | Partially checked | 5013
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
...
Bibliography
| [ISO/IEC 9899:20112024] | 7.2123.3, "Files" |
...