-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathDoNotCopyAFileObject.ql
More file actions
38 lines (35 loc) · 1.05 KB
/
DoNotCopyAFileObject.ql
File metadata and controls
38 lines (35 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* @id c/cert/do-not-copy-a-file-object
* @name FIO38-C: Do not copy a FILE object
* @description Using a copy of a FILE object may result in program failure.
* @kind problem
* @precision very-high
* @problem.severity error
* @tags external/cert/id/fio38-c
* correctness
* security
* external/cert/severity/low
* external/cert/likelihood/probable
* external/cert/remediation-cost/medium
* external/cert/priority/p4
* external/cert/level/l3
* coding-standards/baseline/safety
* external/cert/obligation/rule
*/
import cpp
import codingstandards.c.cert
/**
* An object being copied as part of an Initialization, Assignment or Function Call
*/
class CopiedObject extends Expr {
CopiedObject() {
this = any(Initializer i).getExpr() or
this = any(Assignment a).getRValue() or
this = any(FunctionCall fc).getAnArgument()
}
}
from CopiedObject o
where
not isExcluded(o, IO2Package::doNotCopyAFileObjectQuery()) and
o.getType().hasName("FILE")
select o, "A FILE object is being copied."