From: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-network 1/2] fix #7077: Improve error messages for ID length mismatch
Date: Wed, 21 Jan 2026 11:32:32 +0100 [thread overview]
Message-ID: <20260121103407.187187-5-a.bied-charreton@proxmox.com> (raw)
In-Reply-To: <20260121103407.187187-1-a.bied-charreton@proxmox.com>
Add explicit length checks to ID validation functions to provide clearer
error messages in case of length mismatches
Signed-off-by: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
---
src/PVE/Network/SDN/Controllers/Plugin.pm | 5 +++++
src/PVE/Network/SDN/Dns/Plugin.pm | 5 +++++
src/PVE/Network/SDN/Fabrics.pm | 5 +++++
src/PVE/Network/SDN/Ipams/Plugin.pm | 5 +++++
src/PVE/Network/SDN/VnetPlugin.pm | 5 +++++
src/PVE/Network/SDN/Zones/Plugin.pm | 5 +++++
6 files changed, 30 insertions(+)
diff --git a/src/PVE/Network/SDN/Controllers/Plugin.pm b/src/PVE/Network/SDN/Controllers/Plugin.pm
index d70e518..f117f28 100644
--- a/src/PVE/Network/SDN/Controllers/Plugin.pm
+++ b/src/PVE/Network/SDN/Controllers/Plugin.pm
@@ -30,6 +30,11 @@ PVE::JSONSchema::register_format('pve-sdn-controller-id', \&parse_sdn_controller
sub parse_sdn_controller_id {
my ($id, $noerr) = @_;
+ if (length($id) < 2) {
+ return undef if $noerr;
+ die "controller ID '$id' can't be shorter than 2 characters\n";
+ }
+
if ($id !~ m/^[a-z][a-z0-9_-]*[a-z0-9]$/i) {
return undef if $noerr;
die "controller ID '$id' contains illegal characters\n";
diff --git a/src/PVE/Network/SDN/Dns/Plugin.pm b/src/PVE/Network/SDN/Dns/Plugin.pm
index 2864d4c..68a07fa 100644
--- a/src/PVE/Network/SDN/Dns/Plugin.pm
+++ b/src/PVE/Network/SDN/Dns/Plugin.pm
@@ -32,6 +32,11 @@ PVE::JSONSchema::register_format('pve-sdn-dns-id', \&parse_sdn_dns_id);
sub parse_sdn_dns_id {
my ($id, $noerr) = @_;
+ if (length($id) < 2) {
+ return undef if $noerr;
+ die "dns ID '$id' can't be shorter than 2 characters\n";
+ }
+
if ($id !~ m/^[a-z][a-z0-9]*[a-z0-9]$/i) {
return undef if $noerr;
die "dns ID '$id' contains illegal characters\n";
diff --git a/src/PVE/Network/SDN/Fabrics.pm b/src/PVE/Network/SDN/Fabrics.pm
index d90992a..b18ac7d 100644
--- a/src/PVE/Network/SDN/Fabrics.pm
+++ b/src/PVE/Network/SDN/Fabrics.pm
@@ -13,6 +13,11 @@ PVE::JSONSchema::register_format(
sub {
my ($id, $noerr) = @_;
+ if (length($id) > 8) {
+ return undef if $noerr;
+ die "Fabric ID '$id' can't be longer than 8 characters\n";
+ }
+
if ($id !~ m/^[a-zA-Z0-9][a-zA-Z0-9-]{0,6}[a-zA-Z0-9]?$/i) {
return undef if $noerr;
die "Fabric ID '$id' contains illegal characters\n";
diff --git a/src/PVE/Network/SDN/Ipams/Plugin.pm b/src/PVE/Network/SDN/Ipams/Plugin.pm
index a986a92..10aabea 100644
--- a/src/PVE/Network/SDN/Ipams/Plugin.pm
+++ b/src/PVE/Network/SDN/Ipams/Plugin.pm
@@ -33,6 +33,11 @@ PVE::JSONSchema::register_format('pve-sdn-ipam-id', \&parse_sdn_ipam_id);
sub parse_sdn_ipam_id {
my ($id, $noerr) = @_;
+ if (length($id) < 2) {
+ return undef if $noerr;
+ die "ipam ID '$id' can't be shorter than 2 characters\n";
+ }
+
if ($id !~ m/^[a-z][a-z0-9]*[a-z0-9]$/i) {
return undef if $noerr;
die "ipam ID '$id' contains illegal characters\n";
diff --git a/src/PVE/Network/SDN/VnetPlugin.pm b/src/PVE/Network/SDN/VnetPlugin.pm
index 717438c..a191af1 100644
--- a/src/PVE/Network/SDN/VnetPlugin.pm
+++ b/src/PVE/Network/SDN/VnetPlugin.pm
@@ -30,6 +30,11 @@ PVE::JSONSchema::register_format('pve-sdn-vnet-id', \&parse_sdn_vnet_id);
sub parse_sdn_vnet_id {
my ($id, $noerr) = @_;
+ if (length($id) < 2) {
+ return undef if $noerr;
+ die "vnet ID '$id' can't be shorter than 2 characters\n";
+ }
+
if ($id !~ m/^[a-z][a-z0-9]*[a-z0-9]$/i) {
return undef if $noerr;
die "vnet ID '$id' contains illegal characters\n";
diff --git a/src/PVE/Network/SDN/Zones/Plugin.pm b/src/PVE/Network/SDN/Zones/Plugin.pm
index 826ebdf..14e2634 100644
--- a/src/PVE/Network/SDN/Zones/Plugin.pm
+++ b/src/PVE/Network/SDN/Zones/Plugin.pm
@@ -32,6 +32,11 @@ PVE::JSONSchema::register_format('pve-sdn-zone-id', \&parse_sdn_zone_id);
sub parse_sdn_zone_id {
my ($id, $noerr) = @_;
+ if (length($id) < 2) {
+ return undef if $noerr;
+ die "zone ID '$id' can't be shorter than 2 characters\n";
+ }
+
if ($id !~ m/^[a-z][a-z0-9]*[a-z0-9]$/i) {
return undef if $noerr;
die "zone ID '$id' contains illegal characters\n";
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2026-01-21 10:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-21 10:32 [pve-devel] [PATCH 0/5] fix #7077: Improve ID validation error messages Arthur Bied-Charreton
2026-01-21 10:32 ` [pve-devel] [PATCH pve-common] fix #7077: Improve error message for IDs shorter than 2 characters Arthur Bied-Charreton
2026-01-21 18:00 ` [pve-devel] applied: " Thomas Lamprecht
2026-01-21 10:32 ` [pve-devel] [PATCH pve-storage] fix #7077: Improve error message for IDS " Arthur Bied-Charreton
2026-01-21 10:32 ` [pve-devel] [PATCH proxmox] fix #7077: Improve error message for SDN IDs " Arthur Bied-Charreton
2026-01-21 10:32 ` Arthur Bied-Charreton [this message]
2026-01-21 10:32 ` [pve-devel] [PATCH pve-network 2/2] fix #7077: Respect noerr flag in SDN ID validation Arthur Bied-Charreton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260121103407.187187-5-a.bied-charreton@proxmox.com \
--to=a.bied-charreton@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox