@@ -73,19 +73,27 @@ abstract private class ScanfFunctionModel extends ArrayFunction, TaintFunction,
7373 * The standard function `scanf` and its assorted variants
7474 */
7575private class ScanfModel extends ScanfFunctionModel , LocalFlowSourceFunction instanceof Scanf {
76- override predicate hasLocalFlowSource ( FunctionOutput output , string description ) {
77- output .isParameterDeref ( any ( int i | i >= this .getArgsStartPosition ( ) ) ) and
78- description = "value read by " + this .getName ( )
76+ override predicate hasLocalFlowSource ( Call call , FunctionOutput output , string description ) {
77+ exists ( ScanfFunctionCall scanfCall , int n | call = scanfCall |
78+ scanfCall .getScanfFunction ( ) = this and
79+ exists ( scanfCall .getOutputArgument ( n ) ) and
80+ output .isParameterDeref ( this .getNumberOfParameters ( ) + n ) and
81+ description = "value read by " + this .getName ( )
82+ )
7983 }
8084}
8185
8286/**
8387 * The standard function `fscanf` and its assorted variants
8488 */
8589private class FscanfModel extends ScanfFunctionModel , RemoteFlowSourceFunction instanceof Fscanf {
86- override predicate hasRemoteFlowSource ( FunctionOutput output , string description ) {
87- output .isParameterDeref ( any ( int i | i >= this .getArgsStartPosition ( ) ) ) and
88- description = "value read by " + this .getName ( )
90+ override predicate hasRemoteFlowSource ( Call call , FunctionOutput output , string description ) {
91+ exists ( ScanfFunctionCall scanfCall , int n | call = scanfCall |
92+ scanfCall .getScanfFunction ( ) = this and
93+ exists ( scanfCall .getOutputArgument ( n ) ) and
94+ output .isParameterDeref ( this .getNumberOfParameters ( ) + n ) and
95+ description = "value read by " + this .getName ( )
96+ )
8997 }
9098
9199 override predicate hasSocketInput ( FunctionInput input ) {
0 commit comments