Skip to content

Commit ec5d8ab

Browse files
committed
Java: Restrict use-use flow
1 parent a1511e1 commit ec5d8ab

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

java/ql/lib/semmle/code/java/dataflow/internal/DataFlowPrivate.qll

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,7 @@ predicate readStep(Node node1, Content f, Node node2) {
139139
*/
140140
predicate clearsContent(Node n, Content c) {
141141
c instanceof FieldContent and
142-
(
143-
n = any(PostUpdateNode pun | storeStep(_, c, pun)).getPreUpdateNode()
144-
or
145-
FlowSummaryImpl::Private::Steps::summaryStoresIntoArg(c, n)
146-
)
142+
n = any(PostUpdateNode pun | storeStep(_, c, pun)).getPreUpdateNode()
147143
or
148144
FlowSummaryImpl::Private::Steps::summaryClearsContent(n, c)
149145
}

java/ql/lib/semmle/code/java/dataflow/internal/DataFlowUtil.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ predicate hasNonlocalValue(FieldRead fr) {
101101
predicate localFlowStep(Node node1, Node node2) {
102102
simpleLocalFlowStep(node1, node2)
103103
or
104+
adjacentUseUse(node1.asExpr(), node2.asExpr())
105+
or
104106
// Simple flow through library code is included in the exposed local
105107
// step relation, even though flow is technically inter-procedural
106108
FlowSummaryImpl::Private::Steps::summaryThroughStep(node1, node2, true)
@@ -131,7 +133,8 @@ predicate simpleLocalFlowStep(Node node1, Node node2) {
131133
adjacentUseUse(node1.asExpr(), node2.asExpr()) and
132134
not exists(FieldRead fr |
133135
hasNonlocalValue(fr) and fr.getField().isStatic() and fr = node1.asExpr()
134-
)
136+
) and
137+
not FlowSummaryImpl::Private::Steps::summaryClearsContentArg(node1, _)
135138
or
136139
ThisFlow::adjacentThisRefs(node1, node2)
137140
or

0 commit comments

Comments
 (0)