From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id C858E1FF09B for ; Mon, 09 Nov 2026 23:07:21 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 1C3BB21250; Mon, 09 Nov 2026 23:07:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stuttgart.de; s=s1022; t=1794261583; bh=LYPYxTPmohFayAABLHFBax5EQFGapbdICXv1wCTRLTo=; h=From:To:Cc:Subject:Date:From; b=JQCwuZW68inCKSchbratwV/UMe0nMPz/Onedzmys57DqbKC8GlK3JGzAZey4pOmIv mEHGfcP6u/Gamez2pAAK4pcJR2GwLLSFAPqRcfCEw9sCCIdbwKOMmUujzptC87HCJV WwWZxuBXb9hbsVlYVBAxR7nOC8i2Jdqc7JdhEl32MInc9CF2lsU0IVVUQPl3m0Cfum uV8gh2ljKVlLS4Xm7/GDNZxBZJYTN0B3uSuA8CefLAkHyGY0pYexzizCZGM4FmsF4F JEUC6gbPbkg09Ra47aSosz7vlcQUUdzJ/BZ2SJZcDXkJYKtrtSmgWygELsmM47rFLY AXO9NTr+ji3rA== From: Jakob-Tobias Winter To: tobias@linuxdingsda.de, pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-backup] bin: debug: api: fix panic on parameters given more than once Date: Mon, 9 Nov 2026 22:59:38 +0100 Message-ID: <20261109215938.903397-1-tobias@stuttgart.de> X-Mailer: git-send-email 2.53.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.133 Adjusted score from AWL reputation of From: address DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_PASS -0.001 SPF: HELO matches SPF record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: ZCNWKBVH3UXQXC2FER5FDQEZ2ZRSPGOK X-Message-ID-Hash: ZCNWKBVH3UXQXC2FER5FDQEZ2ZRSPGOK X-MailFrom: prvs=1120bca8fb=tobias@stuttgart.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Jakob-Tobias Winter X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Array parameters, for example 'group-filter', are set by giving the parameter once per value. The command line parser collects the values of a repeated parameter in an array, while the 'api' subcommands expected a single string for each parameter and panicked with "entered unreachable code". So array parameters could only be passed with one value. Hand each value over to the parameter verification separately. Array parameters now accept more than one value, and other parameters that are given more than once get rejected as duplicate instead of causing a panic. Signed-off-by: Jakob-Tobias Winter --- Reproducer: proxmox-backup-debug api create /config/tape-backup-job --id two \ --store store1 --pool pool1 --drive drive1 \ --group-filter type:vm --group-filter group:ct/200 Tested with debug builds of current master and of 4.2.8, calling the API in-process (PROXMOX_DEBUG_API_CODE=1): the call panics without the patch and creates the job with both filters with it. Calls without a repeated parameter print the same as before. The HTTP path was not tested. src/bin/proxmox_backup_debug/api.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/bin/proxmox_backup_debug/api.rs b/src/bin/proxmox_backup_debug/api.rs index 61cd1b7db..39f8c2100 100644 --- a/src/bin/proxmox_backup_debug/api.rs +++ b/src/bin/proxmox_backup_debug/api.rs @@ -153,15 +153,21 @@ fn merge_parameters( .collect(); if let Some(Value::Object(map)) = param { - param_list.extend(map.into_iter().map(|(k, v)| { - ( - k, - match v { - Value::String(s) => s, - _ => unreachable!(), // we're in the CLI - }, - ) - })); + for (k, v) in map { + match v { + Value::String(s) => param_list.push((k, s)), + // a parameter given more than once is collected into an array + Value::Array(list) => { + for item in list { + match item { + Value::String(s) => param_list.push((k.clone(), s)), + _ => unreachable!(), // we're in the CLI + } + } + } + _ => unreachable!(), // we're in the CLI + } + } } let params = schema.parse_parameter_strings(¶m_list, true)?; -- 2.53.0