Skip to content

Commit 9f3dd63

Browse files
committed
Fixing query to use path graph.
1 parent aa7c677 commit 9f3dd63

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import semmle.code.cpp.ir.dataflow.internal.ModelUtil
2626
import semmle.code.cpp.models.interfaces.DataFlow
2727
import semmle.code.cpp.models.interfaces.Taint
2828
import semmle.code.cpp.ir.IR
29+
import NonConstFlow::PathGraph
2930

3031
class UncalledFunction extends Function {
3132
UncalledFunction() {
@@ -127,11 +128,13 @@ module NonConstFlowConfig implements DataFlow::ConfigSig {
127128

128129
module NonConstFlow = TaintTracking::Global<NonConstFlowConfig>;
129130

130-
from FormattingFunctionCall call, Expr formatString, DataFlow::Node sink
131+
from
132+
FormattingFunctionCall call, Expr formatString, NonConstFlow::PathNode sink,
133+
NonConstFlow::PathNode source
131134
where
135+
isSinkImpl(sink.getNode(), formatString) and
132136
call.getArgument(call.getFormatParameterIndex()) = formatString and
133-
NonConstFlow::flowTo(sink) and
134-
isSinkImpl(sink, formatString)
135-
select formatString,
136-
"The format string argument to " + call.getTarget().getName() +
137-
" should be constant to prevent security issues and other potential errors."
137+
NonConstFlow::flowPath(source, sink)
138+
select sink.getNode(), source, sink,
139+
"The format string argument to $@ has a source which cannot be " +
140+
"verified to originate from a string literal.", call, call.getTarget().getName()

0 commit comments

Comments
 (0)