Skip to content

Commit e65ba13

Browse files
committed
C++: Update NonConstantFormat with DataFlow::ConfigSig
1 parent 661160a commit e65ba13

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

cpp/ql/src/Likely Bugs/Format/NonConstantFormat.ql

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ predicate isNonConst(DataFlow::Node node, boolean isIndirect) {
120120
}
121121

122122
pragma[noinline]
123-
predicate isSanitizerNode(DataFlow::Node node) {
123+
predicate isBarrierNode(DataFlow::Node node) {
124124
underscoreMacro([node.asExpr(), node.asIndirectExpr()])
125125
or
126126
exists(node.asExpr()) and
@@ -132,27 +132,27 @@ predicate isSinkImpl(DataFlow::Node sink, Expr formatString) {
132132
exists(FormattingFunctionCall fc | formatString = fc.getArgument(fc.getFormatParameterIndex()))
133133
}
134134

135-
class NonConstFlow extends TaintTracking::Configuration {
136-
NonConstFlow() { this = "NonConstFlow" }
137-
138-
override predicate isSource(DataFlow::Node source) {
135+
module NonConstFlowConfiguration implements DataFlow::ConfigSig {
136+
predicate isSource(DataFlow::Node source) {
139137
exists(boolean isIndirect, Type t |
140138
isNonConst(source, isIndirect) and
141139
t = source.getType() and
142140
not cannotContainString(t, isIndirect)
143141
)
144142
}
145143

146-
override predicate isSink(DataFlow::Node sink) { isSinkImpl(sink, _) }
144+
predicate isSink(DataFlow::Node sink) { isSinkImpl(sink, _) }
147145

148-
override predicate isSanitizer(DataFlow::Node node) { isSanitizerNode(node) }
146+
predicate isBarrier(DataFlow::Node node) { isBarrierNode(node) }
149147
}
150148

149+
module NonConstFlow = TaintTracking::Make<NonConstFlowConfiguration>;
150+
151151
from FormattingFunctionCall call, Expr formatString
152152
where
153153
call.getArgument(call.getFormatParameterIndex()) = formatString and
154-
exists(NonConstFlow cf, DataFlow::Node sink |
155-
cf.hasFlowTo(sink) and
154+
exists(DataFlow::Node sink |
155+
NonConstFlow::hasFlowTo(sink) and
156156
isSinkImpl(sink, formatString)
157157
)
158158
select formatString,

0 commit comments

Comments
 (0)