@@ -77,23 +77,25 @@ predicate isNonConst(DataFlow::Node node) {
77
77
// i.e., functions that with unknown bodies and are not known to define the output through its input
78
78
// are considered as possible non-const sources
79
79
// The function's output must also not be const to be considered a non-const source
80
- exists ( Call c |
81
- exists ( Expr arg | c .getAnArgument ( ) = arg | arg = node .asDefiningArgument ( ) )
80
+ exists ( Function func , CallInstruction call |
81
+ // NOTE: could use `Call` getAnArgument() instead of `CallInstruction` but requires two
82
+ // variables representing the same call.
83
+ exists ( Expr arg | call .getPositionalArgumentOperand ( _) .getDef ( ) .getUnconvertedResultExpression ( ) = arg and
84
+ arg = node .asDefiningArgument ( )
85
+ )
82
86
or
83
- c = node .asIndirectExpr ( )
84
- ) and
85
- not exists ( FunctionInput input , FunctionOutput output , CallInstruction call |
86
- // NOTE: we must include dataflow and taintflow. e.g., including only dataflow we will find sprintf
87
- // variant function's output are now possible non-const sources
88
- (
89
- pragma [ only_bind_out ] ( call .getStaticCallTarget ( ) )
90
- .( DataFlowFunction )
91
- .hasDataFlow ( input , output ) or
92
- pragma [ only_bind_out ] ( call .getStaticCallTarget ( ) ) .( TaintFunction ) .hasTaintFlow ( input , output )
93
- ) and
94
- node = callOutput ( call , output )
95
- ) and
96
- not exists ( Call c |
87
+ call .getUnconvertedResultExpression ( ) = node .asIndirectExpr ( )
88
+ |
89
+ func = call .getStaticCallTarget ( ) and
90
+ not exists ( FunctionOutput output |
91
+ // NOTE: we must include dataflow and taintflow. e.g., including only dataflow we will find sprintf
92
+ // variant function's output are now possible non-const sources
93
+ pragma [ only_bind_out ] ( func ) .( DataFlowFunction ) .hasDataFlow ( _, output ) or
94
+ pragma [ only_bind_out ] ( func ) .( TaintFunction ) .hasTaintFlow ( _, output )
95
+ |
96
+ node = callOutput ( call , output )
97
+ )
98
+ ) not exists ( Call c |
97
99
c .getTarget ( ) .hasDefinition ( ) and
98
100
if node instanceof DataFlow:: DefinitionByReferenceNode
99
101
then c .getAnArgument ( ) = node .asDefiningArgument ( )
0 commit comments