Skip to content

Commit 8ad6938

Browse files
authored
Merge pull request #19434 from jketema/array-barrier
C++: Limit flow through sinks and sources in `cpp/upcast-array-pointer-arithmetic`
2 parents d7e6e1d + 2ed48ae commit 8ad6938

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

cpp/ql/src/Likely Bugs/Conversion/CastArrayPointerArithmetic.ql

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ module CastToPointerArithFlowConfig implements DataFlow::StateConfigSig {
4444
) and
4545
getFullyConvertedType(node) = state
4646
}
47+
48+
predicate isBarrierIn(DataFlow::Node node) { isSource(node, _) }
49+
50+
predicate isBarrierOut(DataFlow::Node node) { isSink(node, _) }
4751
}
4852

4953
/**

cpp/ql/test/query-tests/Likely Bugs/Conversion/CastArrayPointerArithmetic/CastArrayPointerArithmetic.expected

-18
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,13 @@ edges
33
| test.cpp:30:34:30:34 | b | test.cpp:31:2:31:2 | b | provenance | |
44
| test.cpp:34:31:34:31 | b | test.cpp:35:2:35:2 | b | provenance | |
55
| test.cpp:57:19:57:19 | d | test.cpp:26:29:26:29 | b | provenance | |
6-
| test.cpp:57:19:57:19 | d | test.cpp:58:25:58:25 | d | provenance | |
7-
| test.cpp:57:19:57:19 | d | test.cpp:59:21:59:21 | d | provenance | |
86
| test.cpp:58:25:58:25 | d | test.cpp:30:34:30:34 | b | provenance | |
9-
| test.cpp:58:25:58:25 | d | test.cpp:59:21:59:21 | d | provenance | |
107
| test.cpp:59:21:59:21 | d | test.cpp:34:31:34:31 | b | provenance | |
118
| test.cpp:74:19:74:21 | dss | test.cpp:26:29:26:29 | b | provenance | |
12-
| test.cpp:74:19:74:21 | dss | test.cpp:75:25:75:27 | dss | provenance | |
13-
| test.cpp:74:19:74:21 | dss | test.cpp:76:21:76:23 | dss | provenance | |
149
| test.cpp:75:25:75:27 | dss | test.cpp:30:34:30:34 | b | provenance | |
15-
| test.cpp:75:25:75:27 | dss | test.cpp:76:21:76:23 | dss | provenance | |
1610
| test.cpp:76:21:76:23 | dss | test.cpp:34:31:34:31 | b | provenance | |
1711
| test.cpp:86:19:86:20 | d2 | test.cpp:26:29:26:29 | b | provenance | |
18-
| test.cpp:86:19:86:20 | d2 | test.cpp:87:25:87:26 | d2 | provenance | |
19-
| test.cpp:86:19:86:20 | d2 | test.cpp:88:21:88:22 | d2 | provenance | |
2012
| test.cpp:87:25:87:26 | d2 | test.cpp:30:34:30:34 | b | provenance | |
21-
| test.cpp:87:25:87:26 | d2 | test.cpp:88:21:88:22 | d2 | provenance | |
2213
| test.cpp:88:21:88:22 | d2 | test.cpp:34:31:34:31 | b | provenance | |
2314
nodes
2415
| test.cpp:26:29:26:29 | b | semmle.label | b |
@@ -41,18 +32,9 @@ subpaths
4132
| test.cpp:27:2:27:2 | b | test.cpp:57:19:57:19 | d | test.cpp:27:2:27:2 | b | This pointer arithmetic may be done with the wrong type because of $@. | test.cpp:57:19:57:19 | d | this cast |
4233
| test.cpp:27:2:27:2 | b | test.cpp:74:19:74:21 | dss | test.cpp:27:2:27:2 | b | This pointer arithmetic may be done with the wrong type because of $@. | test.cpp:74:19:74:21 | dss | this cast |
4334
| test.cpp:27:2:27:2 | b | test.cpp:86:19:86:20 | d2 | test.cpp:27:2:27:2 | b | This pointer arithmetic may be done with the wrong type because of $@. | test.cpp:86:19:86:20 | d2 | this cast |
44-
| test.cpp:31:2:31:2 | b | test.cpp:57:19:57:19 | d | test.cpp:31:2:31:2 | b | This pointer arithmetic may be done with the wrong type because of $@. | test.cpp:57:19:57:19 | d | this cast |
4535
| test.cpp:31:2:31:2 | b | test.cpp:58:25:58:25 | d | test.cpp:31:2:31:2 | b | This pointer arithmetic may be done with the wrong type because of $@. | test.cpp:58:25:58:25 | d | this cast |
46-
| test.cpp:31:2:31:2 | b | test.cpp:74:19:74:21 | dss | test.cpp:31:2:31:2 | b | This pointer arithmetic may be done with the wrong type because of $@. | test.cpp:74:19:74:21 | dss | this cast |
4736
| test.cpp:31:2:31:2 | b | test.cpp:75:25:75:27 | dss | test.cpp:31:2:31:2 | b | This pointer arithmetic may be done with the wrong type because of $@. | test.cpp:75:25:75:27 | dss | this cast |
48-
| test.cpp:31:2:31:2 | b | test.cpp:86:19:86:20 | d2 | test.cpp:31:2:31:2 | b | This pointer arithmetic may be done with the wrong type because of $@. | test.cpp:86:19:86:20 | d2 | this cast |
4937
| test.cpp:31:2:31:2 | b | test.cpp:87:25:87:26 | d2 | test.cpp:31:2:31:2 | b | This pointer arithmetic may be done with the wrong type because of $@. | test.cpp:87:25:87:26 | d2 | this cast |
50-
| test.cpp:35:2:35:2 | b | test.cpp:57:19:57:19 | d | test.cpp:35:2:35:2 | b | This pointer arithmetic may be done with the wrong type because of $@. | test.cpp:57:19:57:19 | d | this cast |
51-
| test.cpp:35:2:35:2 | b | test.cpp:58:25:58:25 | d | test.cpp:35:2:35:2 | b | This pointer arithmetic may be done with the wrong type because of $@. | test.cpp:58:25:58:25 | d | this cast |
5238
| test.cpp:35:2:35:2 | b | test.cpp:59:21:59:21 | d | test.cpp:35:2:35:2 | b | This pointer arithmetic may be done with the wrong type because of $@. | test.cpp:59:21:59:21 | d | this cast |
53-
| test.cpp:35:2:35:2 | b | test.cpp:74:19:74:21 | dss | test.cpp:35:2:35:2 | b | This pointer arithmetic may be done with the wrong type because of $@. | test.cpp:74:19:74:21 | dss | this cast |
54-
| test.cpp:35:2:35:2 | b | test.cpp:75:25:75:27 | dss | test.cpp:35:2:35:2 | b | This pointer arithmetic may be done with the wrong type because of $@. | test.cpp:75:25:75:27 | dss | this cast |
5539
| test.cpp:35:2:35:2 | b | test.cpp:76:21:76:23 | dss | test.cpp:35:2:35:2 | b | This pointer arithmetic may be done with the wrong type because of $@. | test.cpp:76:21:76:23 | dss | this cast |
56-
| test.cpp:35:2:35:2 | b | test.cpp:86:19:86:20 | d2 | test.cpp:35:2:35:2 | b | This pointer arithmetic may be done with the wrong type because of $@. | test.cpp:86:19:86:20 | d2 | this cast |
57-
| test.cpp:35:2:35:2 | b | test.cpp:87:25:87:26 | d2 | test.cpp:35:2:35:2 | b | This pointer arithmetic may be done with the wrong type because of $@. | test.cpp:87:25:87:26 | d2 | this cast |
5840
| test.cpp:35:2:35:2 | b | test.cpp:88:21:88:22 | d2 | test.cpp:35:2:35:2 | b | This pointer arithmetic may be done with the wrong type because of $@. | test.cpp:88:21:88:22 | d2 | this cast |

0 commit comments

Comments
 (0)