Skip to content

Commit 9ca601a

Browse files
committed
Convert EXP37-C to the new dataflow library
1 parent 15b9143 commit 9ca601a

File tree

2 files changed

+33
-20
lines changed

2 files changed

+33
-20
lines changed

c/cert/src/rules/EXP37-C/DoNotCallFunctionPointerWithIncompatibleType.ql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import cpp
2020
import codingstandards.c.cert
21-
import semmle.code.cpp.dataflow.DataFlow
21+
import semmle.code.cpp.dataflow.new.DataFlow
2222
import SuspectFunctionPointerToCallFlow::PathGraph
2323

2424
/**
@@ -61,7 +61,8 @@ where
6161
not isExcluded(src.getNode().asExpr(),
6262
ExpressionsPackage::doNotCallFunctionPointerWithIncompatibleTypeQuery()) and
6363
access = src.getNode().asExpr() and
64-
SuspectFunctionPointerToCallFlow::flowPath(src, sink)
64+
SuspectFunctionPointerToCallFlow::flowPath(src, sink) and
65+
not src.getNode().asExpr().getType() = sink.getNode().asExpr().getFullyConverted().getType()
6566
select src, src, sink,
6667
"Incompatible function $@ assigned to function pointer is eventually called through the pointer.",
6768
access.getTarget(), access.getTarget().getName()
Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,40 @@
1-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DoNotCallFunctionPointerWithIncompatibleType.ql:45,54-62)
2-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DoNotCallFunctionPointerWithIncompatibleType.ql:46,22-30)
3-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DoNotCallFunctionPointerWithIncompatibleType.ql:50,20-28)
4-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (DoNotCallFunctionPointerWithIncompatibleType.ql:55,43-51)
51
edges
6-
| test.c:48:68:48:70 | fns [f1] | test.c:49:3:49:5 | fns [f1] | provenance | |
7-
| test.c:49:3:49:5 | fns [f1] | test.c:49:8:49:9 | f1 | provenance | |
8-
| test.c:61:28:61:29 | f2 | test.c:62:3:62:11 | v1_called | provenance | |
9-
| test.c:73:3:73:5 | fns [post update] [f1] | test.c:75:45:75:48 | & ... [f1] | provenance | |
10-
| test.c:73:3:73:13 | ... = ... | test.c:73:3:73:5 | fns [post update] [f1] | provenance | |
2+
| test.c:48:68:48:70 | *fns [f1] | test.c:49:3:49:5 | *fns [f1] | provenance | |
3+
| test.c:48:68:48:70 | *fns [f2] | test.c:50:3:50:5 | *fns [f2] | provenance | |
4+
| test.c:49:3:49:5 | *fns [f1] | test.c:49:8:49:9 | f1 | provenance | |
5+
| test.c:50:3:50:5 | *fns [f2] | test.c:50:8:50:9 | f2 | provenance | |
6+
| test.c:61:3:61:29 | ... = ... | test.c:62:3:62:11 | v1_called | provenance | |
7+
| test.c:61:15:61:29 | f2 | test.c:61:3:61:29 | ... = ... | provenance | |
8+
| test.c:73:3:73:5 | *fns [post update] [f1] | test.c:74:3:74:5 | *fns [f1] | provenance | |
9+
| test.c:73:3:73:13 | ... = ... | test.c:73:3:73:5 | *fns [post update] [f1] | provenance | |
1110
| test.c:73:12:73:13 | v2 | test.c:73:3:73:13 | ... = ... | provenance | |
12-
| test.c:75:45:75:48 | & ... [f1] | test.c:48:68:48:70 | fns [f1] | provenance | |
11+
| test.c:73:12:73:13 | v2 | test.c:74:3:74:13 | ... = ... | provenance | |
12+
| test.c:74:3:74:5 | *fns [f1] | test.c:75:45:75:48 | *& ... [f1] | provenance | |
13+
| test.c:74:3:74:5 | *fns [post update] [f2] | test.c:75:45:75:48 | *& ... [f2] | provenance | |
14+
| test.c:74:3:74:13 | ... = ... | test.c:74:3:74:5 | *fns [post update] [f2] | provenance | |
15+
| test.c:75:45:75:48 | *& ... [f1] | test.c:48:68:48:70 | *fns [f1] | provenance | |
16+
| test.c:75:45:75:48 | *& ... [f2] | test.c:48:68:48:70 | *fns [f2] | provenance | |
1317
nodes
14-
| test.c:48:68:48:70 | fns [f1] | semmle.label | fns [f1] |
15-
| test.c:49:3:49:5 | fns [f1] | semmle.label | fns [f1] |
18+
| test.c:48:68:48:70 | *fns [f1] | semmle.label | *fns [f1] |
19+
| test.c:48:68:48:70 | *fns [f2] | semmle.label | *fns [f2] |
20+
| test.c:49:3:49:5 | *fns [f1] | semmle.label | *fns [f1] |
1621
| test.c:49:8:49:9 | f1 | semmle.label | f1 |
17-
| test.c:61:28:61:29 | f2 | semmle.label | f2 |
22+
| test.c:50:3:50:5 | *fns [f2] | semmle.label | *fns [f2] |
23+
| test.c:50:8:50:9 | f2 | semmle.label | f2 |
24+
| test.c:61:3:61:29 | ... = ... | semmle.label | ... = ... |
25+
| test.c:61:15:61:29 | f2 | semmle.label | f2 |
1826
| test.c:62:3:62:11 | v1_called | semmle.label | v1_called |
19-
| test.c:70:9:70:17 | v3_called | semmle.label | v3_called |
20-
| test.c:73:3:73:5 | fns [post update] [f1] | semmle.label | fns [post update] [f1] |
27+
| test.c:70:4:70:17 | v3_called | semmle.label | v3_called |
28+
| test.c:73:3:73:5 | *fns [post update] [f1] | semmle.label | *fns [post update] [f1] |
2129
| test.c:73:3:73:13 | ... = ... | semmle.label | ... = ... |
2230
| test.c:73:12:73:13 | v2 | semmle.label | v2 |
23-
| test.c:75:45:75:48 | & ... [f1] | semmle.label | & ... [f1] |
31+
| test.c:74:3:74:5 | *fns [f1] | semmle.label | *fns [f1] |
32+
| test.c:74:3:74:5 | *fns [post update] [f2] | semmle.label | *fns [post update] [f2] |
33+
| test.c:74:3:74:13 | ... = ... | semmle.label | ... = ... |
34+
| test.c:75:45:75:48 | *& ... [f1] | semmle.label | *& ... [f1] |
35+
| test.c:75:45:75:48 | *& ... [f2] | semmle.label | *& ... [f2] |
2436
subpaths
2537
#select
26-
| test.c:61:28:61:29 | f2 | test.c:61:28:61:29 | f2 | test.c:62:3:62:11 | v1_called | Incompatible function $@ assigned to function pointer is eventually called through the pointer. | test.c:41:13:41:14 | f2 | f2 |
27-
| test.c:70:9:70:17 | v3_called | test.c:70:9:70:17 | v3_called | test.c:70:9:70:17 | v3_called | Incompatible function $@ assigned to function pointer is eventually called through the pointer. | test.c:58:7:58:15 | v3_called | v3_called |
38+
| test.c:61:15:61:29 | f2 | test.c:61:15:61:29 | f2 | test.c:62:3:62:11 | v1_called | Incompatible function $@ assigned to function pointer is eventually called through the pointer. | test.c:41:13:41:14 | f2 | f2 |
39+
| test.c:70:4:70:17 | v3_called | test.c:70:4:70:17 | v3_called | test.c:70:4:70:17 | v3_called | Incompatible function $@ assigned to function pointer is eventually called through the pointer. | test.c:58:7:58:15 | v3_called | v3_called |
2840
| test.c:73:12:73:13 | v2 | test.c:73:12:73:13 | v2 | test.c:49:8:49:9 | f1 | Incompatible function $@ assigned to function pointer is eventually called through the pointer. | test.c:56:7:56:8 | v2 | v2 |

0 commit comments

Comments
 (0)