@@ -9,6 +9,7 @@ private import semmle.code.cpp.ir.dataflow.internal.DataFlowPrivate
99private import semmle.code.cpp.ir.dataflow.internal.DataFlowUtil
1010private import semmle.code.cpp.ir.dataflow.internal.DataFlowImplSpecific as DataFlowImplSpecific
1111private import semmle.code.cpp.dataflow.ExternalFlow
12+ private import semmle.code.cpp.ir.IR
1213
1314module Input implements InputSig< DataFlowImplSpecific:: CppDataFlow > {
1415 class SummarizedCallableBase = Function ;
@@ -165,6 +166,21 @@ module SourceSinkInterpretationInput implements
165166 c = "" and
166167 e .getQualifier ( ) = n .asExpr ( )
167168 or
169+ // Allow variables (without a qualifier) to be picked as input nodes.
170+ // We could simply do this as `e = n.asExpr()`, but that would not allow
171+ // us to pick `x` as a sink in an example such as `x = source()` (but
172+ // only subsequent uses of `x`) since the variable access on `x` doesn't
173+ // actually load the value of `x`. So instead, we pick the instruction
174+ // node corresponding to the generated `StoreInstruction` and use the
175+ // expression associated with the destination instruction. This means
176+ // that the `x` in `x = source()` can be marked as an input.
177+ c = "" and
178+ not exists ( e .getQualifier ( ) ) and
179+ exists ( StoreInstruction store |
180+ store .getDestinationAddress ( ) .getUnconvertedResultExpression ( ) = e and
181+ n .asInstruction ( ) = store
182+ )
183+ or
168184 // Allow post update nodes to be picked as input nodes when the `input` column
169185 // of the row is `PostUpdate`.
170186 c = "PostUpdate" and
0 commit comments