@@ -26,6 +26,7 @@ import semmle.code.cpp.ir.dataflow.internal.ModelUtil
26
26
import semmle.code.cpp.models.interfaces.DataFlow
27
27
import semmle.code.cpp.models.interfaces.Taint
28
28
import semmle.code.cpp.ir.IR
29
+ import NonConstFlow:: PathGraph
29
30
30
31
class UncalledFunction extends Function {
31
32
UncalledFunction ( ) {
@@ -127,11 +128,13 @@ module NonConstFlowConfig implements DataFlow::ConfigSig {
127
128
128
129
module NonConstFlow = TaintTracking:: Global< NonConstFlowConfig > ;
129
130
130
- from FormattingFunctionCall call , Expr formatString , DataFlow:: Node sink
131
+ from
132
+ FormattingFunctionCall call , Expr formatString , NonConstFlow:: PathNode sink ,
133
+ NonConstFlow:: PathNode source
131
134
where
135
+ isSinkImpl ( sink .getNode ( ) , formatString ) and
132
136
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