Skip to content

Commit a7d7a2c

Browse files
committed
Rust: Ensure index expressions are not handled as calls yet
1 parent d85a0f0 commit a7d7a2c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,13 @@ final class ArgumentPosition extends ParameterPosition {
145145
* as the synthetic `ReceiverNode` is the argument for the `self` parameter.
146146
*/
147147
predicate isArgumentForCall(ExprCfgNode arg, CallCfgNode call, ParameterPosition pos) {
148-
call.getPositionalArgument(pos.getPosition()) = arg
149-
or
150-
call.getReceiver() = arg and pos.isSelf() and not call.getCall().receiverImplicitlyBorrowed()
148+
// TODO: Handle index expressions as calls in data flow.
149+
not call.getCall() instanceof IndexExpr and
150+
(
151+
call.getPositionalArgument(pos.getPosition()) = arg
152+
or
153+
call.getReceiver() = arg and pos.isSelf() and not call.getCall().receiverImplicitlyBorrowed()
154+
)
151155
}
152156

153157
/** Provides logic related to SSA. */

rust/ql/lib/codeql/rust/dataflow/internal/Node.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,11 @@ newtype TNode =
472472
getPostUpdateReverseStep(any(PostUpdateNode n).getPreUpdateNode().asExpr(), _)
473473
]
474474
} or
475-
TReceiverNode(CallCfgNode mc, Boolean isPost) { mc.getCall().receiverImplicitlyBorrowed() } or
475+
TReceiverNode(CallCfgNode mc, Boolean isPost) {
476+
mc.getCall().receiverImplicitlyBorrowed() and
477+
// TODO: Handle index expressions as calls in data flow.
478+
not mc.getCall() instanceof IndexExpr
479+
} or
476480
TSsaNode(SsaImpl::DataFlowIntegration::SsaNode node) or
477481
TFlowSummaryNode(FlowSummaryImpl::Private::SummaryNode sn) or
478482
TClosureSelfReferenceNode(CfgScope c) { lambdaCreationExpr(c, _) } or

0 commit comments

Comments
 (0)