From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 1B5591FF170 for ; Tue, 19 Nov 2024 16:40:51 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1AB1B2F55C; Tue, 19 Nov 2024 16:40:56 +0100 (CET) Date: Tue, 19 Nov 2024 16:40:52 +0100 From: Christoph Heiss To: Filip Schauer Message-ID: References: <20241119145934.102126-1-f.schauer@proxmox.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20241119145934.102126-1-f.schauer@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.029 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH installer] fetch-answer: encode unsafe characters in partition label X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Cc: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Good catch & thanks for tackeling this! Also tested it with a simple whitespace character. Tested-by: Christoph Heiss Reviewed-by: Christoph Heiss On Tue, Nov 19, 2024 at 03:59:34PM +0100, Filip Schauer wrote: > Ensure potentially unsafe characters in the partition label are encoded, > preventing the installer from failing to find the answer partition when > the label contains whitespaces or !"$%&'()*,/;<>?[\]^`{|}~ > [..] > --- > .../src/fetch_plugins/partition.rs | 30 ++++++++++++++----- > 1 file changed, 22 insertions(+), 8 deletions(-) > [..] > @@ -52,20 +65,21 @@ fn path_exists_logged(file_name: &str, search_path: &str) -> Option { > /// * `partlabel_source` - Partition Label, used for matching, in the exact, upper and lower case > /// * `search_path` - Path where to search for the partition label > fn scan_partlabels(partlabel: &str, search_path: &str) -> Result { > - if let Some(path) = path_exists_logged(partlabel, search_path) { > - info!("Found partition with label '{partlabel}'"); > + let partlabel_enc = encode_partlabel(partlabel); > + if let Some(path) = path_exists_logged(&partlabel_enc, search_path) { > + info!("Found partition with label '{partlabel_enc}'"); I think the original, non-encoded partition label should be printed here. As it would be somewhat surprising to users/administrators to suddenly see some partition label being searched that what the specified -- thus considering this as an internal implementation detail, not public interface. > return Ok(path); > } > > - let partlabel_upper_case = partlabel.to_uppercase(); > - if let Some(path) = path_exists_logged(&partlabel_upper_case, search_path) { > - info!("Found partition with label '{partlabel_upper_case}'"); > + let partlabel_upper_case_enc = encode_partlabel(&partlabel.to_uppercase()); > + if let Some(path) = path_exists_logged(&partlabel_upper_case_enc, search_path) { > + info!("Found partition with label '{partlabel_upper_case_enc}'"); .. same here .. > return Ok(path); > } > > - let partlabel_lower_case = partlabel.to_lowercase(); > - if let Some(path) = path_exists_logged(&partlabel_lower_case, search_path) { > - info!("Found partition with label '{partlabel_lower_case}'"); > + let partlabel_lower_case_enc = encode_partlabel(&partlabel.to_lowercase()); > + if let Some(path) = path_exists_logged(&partlabel_lower_case_enc, search_path) { > + info!("Found partition with label '{partlabel_lower_case_enc}'"); .. and here. _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel