From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id CBD3D917C1 for ; Thu, 15 Feb 2024 13:40:14 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B59AE12FFE for ; Thu, 15 Feb 2024 13:40:14 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 15 Feb 2024 13:40:13 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id AA96A4845F for ; Thu, 15 Feb 2024 13:40:13 +0100 (CET) From: Christoph Heiss To: pve-devel@lists.proxmox.com Date: Thu, 15 Feb 2024 13:39:38 +0100 Message-ID: <20240215124004.1197676-6-c.heiss@proxmox.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215124004.1197676-1-c.heiss@proxmox.com> References: <20240215124004.1197676-1-c.heiss@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.004 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH installer 5/5] fix #5230: sys: net: properly escape FQDN regex 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: , X-List-Received-Date: Thu, 15 Feb 2024 12:40:14 -0000 Due to interpolation, the \. sequence must be double-escaped. Previously, this would result in a non-escaped dot, thus matching much more liberally than it should. Signed-off-by: Christoph Heiss --- Proxmox/Sys/Net.pm | 2 +- proxmox-installer-common/src/utils.rs | 6 ++++++ test/parse-fqdn.pl | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Proxmox/Sys/Net.pm b/Proxmox/Sys/Net.pm index 2d29116..c2f3e9c 100644 --- a/Proxmox/Sys/Net.pm +++ b/Proxmox/Sys/Net.pm @@ -7,7 +7,7 @@ use base qw(Exporter); our @EXPORT_OK = qw(parse_ip_address parse_ip_mask parse_fqdn); our $HOSTNAME_RE = "(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-]{,61}?[a-zA-Z0-9])?)"; -our $FQDN_RE = "(?:${HOSTNAME_RE}\.)*${HOSTNAME_RE}"; +our $FQDN_RE = "(?:${HOSTNAME_RE}\\.)*${HOSTNAME_RE}"; my $IPV4OCTET = "(?:25[0-5]|(?:2[0-4]|1[0-9]|[1-9])?[0-9])"; my $IPV4RE = "(?:(?:$IPV4OCTET\\.){3}$IPV4OCTET)"; diff --git a/proxmox-installer-common/src/utils.rs b/proxmox-installer-common/src/utils.rs index 0ed7438..03efdd7 100644 --- a/proxmox-installer-common/src/utils.rs +++ b/proxmox-installer-common/src/utils.rs @@ -309,6 +309,12 @@ mod tests { Fqdn::from(&format!("{}.com", "a".repeat(64))), Err(InvalidPart("a".repeat(64))), ); + + // https://bugzilla.proxmox.com/show_bug.cgi?id=3497 + assert_eq!( + Fqdn::from("123@foo.com"), + Err(InvalidPart("123@foo".to_owned())) + ); } #[test] diff --git a/test/parse-fqdn.pl b/test/parse-fqdn.pl index 3009984..df8739d 100755 --- a/test/parse-fqdn.pl +++ b/test/parse-fqdn.pl @@ -51,4 +51,7 @@ is_parsed('a' x 63 . '.com', ['a' x 63, 'com']); is_invalid('a' x 250 . '.com', ERR_TOOLONG); is_invalid('a' x 64 . '.com', ERR_ALPHANUM); +# https://bugzilla.proxmox.com/show_bug.cgi?id=3497 +is_invalid('123@foo.com', ERR_ALPHANUM); + done_testing(); -- 2.43.0