Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a962cff

Browse files
committed
[CPP-370] Intermediate commit, file not in usable state.
1 parent fae55d5 commit a962cff

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,16 @@ predicate isConst(Expr e) {
6565
whitelisted(e)
6666
}
6767

68-
class ConstFlow extends DataFlow::Configuration {
69-
ConstFlow() { this = "ConstFlow" }
68+
class NonConstFlow extends DataFlow::Configuration {
69+
NonConstFlow() { this = "NonConstFlow" }
7070

71-
override predicate isSource(DataFlow::Node source) { isConst(source.asExpr()) }
71+
override predicate isSource(DataFlow::Node source) { isNonConst(source.asExpr()) }
7272

7373
override predicate isSink(DataFlow::Node sink) {
7474
exists(FormattingFunctionCall fc | sink.asExpr() = fc.getArgument(fc.getFormatParameterIndex()))
7575
}
7676

7777
override predicate isAdditionalFlowStep(DataFlow::Node source, DataFlow::Node sink) {
78-
none()
79-
or
8078
// an element picked from an array of string literals is a string literal
8179
exists(Variable v, int a |
8280
a = sink.asExpr().(ArrayExpr).getArrayOffset().getValue().toInt() and
@@ -92,10 +90,10 @@ class ConstFlow extends DataFlow::Configuration {
9290
from FormattingFunctionCall call, Expr formatString
9391
where
9492
call.getArgument(call.getFormatParameterIndex()) = formatString and
95-
not exists(ConstFlow cf, DataFlow::Node source, DataFlow::Node sink |
93+
exists(NonConstFlow cf, DataFlow::Node source, DataFlow::Node sink |
9694
cf.hasFlow(source, sink) and
9795
sink.asExpr() = formatString
9896
)
99-
select call,
97+
select formatString,
10098
"The format string argument to " + call.getTarget().getQualifiedName() +
10199
" should be constant to prevent security issues and other potential errors."

0 commit comments

Comments
 (0)