Skip to content

Commit 4f9bdca

Browse files
committed
C++: Optimize.
1 parent cedbfbe commit 4f9bdca

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

cpp/ql/src/Security/CWE/CWE-843/TypeConfusion.ql

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,16 +219,14 @@ module RelevantStateConfig implements DataFlow::ConfigSig {
219219

220220
module RelevantStateFlow = DataFlow::Global<RelevantStateConfig>;
221221

222-
predicate relevantState(DataFlow::Node sink, Class state) {
223-
exists(DataFlow::Node source |
224-
RelevantStateFlow::flow(source, sink) and
225-
isSourceImpl(source, state)
226-
)
222+
predicate relevantState(DataFlow::Node source, DataFlow::Node sink, Class state) {
223+
RelevantStateFlow::flow(source, sink) and
224+
isSourceImpl(source, state)
227225
}
228226

229227
predicate isSinkImpl(DataFlow::Node sink, Class state, Type convertedType, boolean compatible) {
230228
exists(UnsafeCast cast |
231-
relevantState(sink, state) and
229+
relevantState(_, sink, state) and
232230
sink.asExpr() = cast.getUnconverted() and
233231
convertedType = cast.getConvertedType()
234232
|
@@ -245,10 +243,10 @@ predicate isSinkImpl(DataFlow::Node sink, Class state, Type convertedType, boole
245243
*/
246244
module BadConfig implements DataFlow::StateConfigSig {
247245
class FlowState extends Class {
248-
FlowState() { relevantState(_, this) }
246+
FlowState() { relevantState(_, _, this) }
249247
}
250248

251-
predicate isSource(DataFlow::Node source, FlowState state) { isSourceImpl(source, state) }
249+
predicate isSource(DataFlow::Node source, FlowState state) { relevantState(source, _, state) }
252250

253251
predicate isBarrier(DataFlow::Node node) { RelevantStateConfig::isBarrier(node) }
254252

0 commit comments

Comments
 (0)