Skip to content

Commit bfdf262

Browse files
committed
C++: Block flow into thread-specific storage creating functions (i.e., *almost* the sources of the query) to remove false negatives.
1 parent a7924d5 commit bfdf262

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

c/cert/src/rules/CON30-C/CleanUpThreadSpecificStorage.ql

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,28 @@ import codingstandards.c.cert
2222
import codingstandards.cpp.ConcurrencyNew
2323
import semmle.code.cpp.dataflow.new.DataFlow
2424

25+
newtype Direction =
26+
Incoming() or
27+
Outgoing()
28+
29+
predicate isSource(DataFlow::Node node, Direction d) {
30+
exists(TSSCreateFunctionCall tsc, Expr e |
31+
// the only requirement of the source is that at some point
32+
// it refers to the key of a create statement
33+
e.getParent*() = tsc.getKey()
34+
|
35+
d = Outgoing() and
36+
e = [node.asExpr(), node.asDefiningArgument()]
37+
or
38+
d = Incoming() and
39+
e = [node.asExpr(), node.asIndirectArgument()]
40+
)
41+
}
42+
2543
module TssCreateToTssDeleteConfig implements DataFlow::ConfigSig {
26-
predicate isSource(DataFlow::Node node) {
27-
exists(TSSCreateFunctionCall tsc, Expr e |
28-
// the only requirement of the source is that at some point
29-
// it refers to the key of a create statement
30-
e.getParent*() = tsc.getKey() and
31-
(e = node.asDefiningArgument() or e = node.asExpr())
32-
)
33-
}
44+
predicate isSource(DataFlow::Node node) { isSource(node, Outgoing()) }
45+
46+
predicate isBarrierIn(DataFlow::Node node) { isSource(node, Incoming()) }
3447

3548
predicate isSink(DataFlow::Node node) {
3649
exists(TSSDeleteFunctionCall tsd, Expr e |

0 commit comments

Comments
 (0)