@@ -26,6 +26,7 @@ import semmle.code.cpp.ir.dataflow.internal.ModelUtil
2626import semmle.code.cpp.models.interfaces.DataFlow
2727import semmle.code.cpp.models.interfaces.Taint
2828import semmle.code.cpp.ir.IR
29+ import NonConstFlow:: PathGraph
2930
3031class UncalledFunction extends Function {
3132 UncalledFunction ( ) {
@@ -127,11 +128,13 @@ module NonConstFlowConfig implements DataFlow::ConfigSig {
127128
128129module 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
131134where
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