Skip to content

Commit 333d0a6

Browse files
committed
Java/C++/C#: Bugfix for field flow through reverse read.
1 parent d59ea3d commit 333d0a6

File tree

6 files changed

+40
-4
lines changed

6 files changed

+40
-4
lines changed

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ private module ImplCommon {
360360
*/
361361
cached
362362
predicate read(Node node1, Content f, Node node2) {
363-
readStep(node1, f, node2) and storeStep(_, f, _)
363+
readStep(node1, f, node2)
364364
or
365365
exists(DataFlowCall call, ReturnKind kind |
366366
read0(call, kind, node1, f) and

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ private module ImplCommon {
360360
*/
361361
cached
362362
predicate read(Node node1, Content f, Node node2) {
363-
readStep(node1, f, node2) and storeStep(_, f, _)
363+
readStep(node1, f, node2)
364364
or
365365
exists(DataFlowCall call, ReturnKind kind |
366366
read0(call, kind, node1, f) and

csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ private module ImplCommon {
360360
*/
361361
cached
362362
predicate read(Node node1, Content f, Node node2) {
363-
readStep(node1, f, node2) and storeStep(_, f, _)
363+
readStep(node1, f, node2)
364364
or
365365
exists(DataFlowCall call, ReturnKind kind |
366366
read0(call, kind, node1, f) and

java/ql/src/semmle/code/java/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ private module ImplCommon {
360360
*/
361361
cached
362362
predicate read(Node node1, Content f, Node node2) {
363-
readStep(node1, f, node2) and storeStep(_, f, _)
363+
readStep(node1, f, node2)
364364
or
365365
exists(DataFlowCall call, ReturnKind kind |
366366
read0(call, kind, node1, f) and
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
public class E {
2+
static Object src() { return new Object(); }
3+
static void sink(Object obj) {}
4+
5+
static class Buffer { Object content; }
6+
static class BufHolder { Buffer buf; }
7+
static class Packet { BufHolder data; }
8+
9+
static void recv(Buffer buf) {
10+
buf.content = src();
11+
}
12+
13+
static void foo(Buffer raw, BufHolder bh, Packet p) {
14+
recv(raw);
15+
recv(bh.buf);
16+
recv(p.data.buf);
17+
18+
sink(raw.content);
19+
20+
BufHolder bh2 = bh;
21+
sink(bh2.buf.content);
22+
23+
Packet p2 = p;
24+
sink(p2.data.buf.content);
25+
26+
handlepacket(p);
27+
}
28+
29+
static void handlepacket(Packet p) {
30+
sink(p.data.buf.content);
31+
}
32+
}

java/ql/test/library-tests/dataflow/fields/flow.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@
2222
| D.java:19:14:19:23 | new Elem(...) | D.java:33:10:33:31 | getElem(...) |
2323
| D.java:26:14:26:23 | new Elem(...) | D.java:33:10:33:31 | getElem(...) |
2424
| D.java:37:14:37:23 | new Elem(...) | D.java:44:10:44:26 | boxfield.box.elem |
25+
| E.java:2:32:2:43 | new Object(...) | E.java:18:10:18:20 | raw.content |
26+
| E.java:2:32:2:43 | new Object(...) | E.java:21:10:21:24 | bh2.buf.content |
27+
| E.java:2:32:2:43 | new Object(...) | E.java:24:10:24:28 | p2.data.buf.content |
28+
| E.java:2:32:2:43 | new Object(...) | E.java:30:10:30:27 | p.data.buf.content |

0 commit comments

Comments
 (0)