From 2448475141bae32f8f393efbd5dea890c5cfb26b Mon Sep 17 00:00:00 2001 From: Mathias Vorreiter Pedersen Date: Fri, 17 Jan 2025 21:04:49 +0000 Subject: [PATCH] C++: Ensure that 'argumentOf' does not map to multiple argument positions. --- .../semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll | 2 +- .../lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll index 7b89e9714ff0..40740d956dcd 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll @@ -382,7 +382,7 @@ private class SideEffectArgumentNode extends ArgumentNode, SideEffectOperandNode exists(int indirectionIndex | pos = TIndirectionPosition(argumentIndex, pragma[only_bind_into](indirectionIndex)) and this.getCallInstruction() = dfCall.asCallInstruction() and - super.hasAddressOperandAndIndirectionIndex(_, pragma[only_bind_into](indirectionIndex)) + super.hasAddressOperandAndIndirectionIndex(arg, pragma[only_bind_into](indirectionIndex)) ) } } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll index 4dabd917b3d3..34401de1b127 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll @@ -757,9 +757,11 @@ class SsaIteratorNode extends Node, TSsaIteratorNode { class SideEffectOperandNode extends Node instanceof IndirectOperand { CallInstruction call; int argumentIndex; + ArgumentOperand arg; SideEffectOperandNode() { - IndirectOperand.super.hasOperandAndIndirectionIndex(call.getArgumentOperand(argumentIndex), _) + arg = call.getArgumentOperand(argumentIndex) and + IndirectOperand.super.hasOperandAndIndirectionIndex(arg, _) } CallInstruction getCallInstruction() { result = call }