diff options
| author | Stefan Hanreich <s.hanreich@proxmox.com> | 2025-03-07 13:50:55 +0100 |
|---|---|---|
| committer | Thomas Lamprecht <t.lamprecht@proxmox.com> | 2025-04-07 18:35:40 +0200 |
| commit | f5ad8efc4e5fadd24311c06afb2c93a0eb65a575 (patch) | |
| tree | bfbb997a3eb74c736f1174b4f571684eae153901 | |
| parent | e62b892fdc5d6b94d61af5424a6957983fbeeb29 (diff) | |
subnet: dhcp: only accept single ips and normalize them
Net::IP accepts a myriad of different IP objects from ranges to
prefixes to singular IPs. We check if the object consists only of a
singular IP and normalize the IP if it has size 1 (since then it
could still be a /32 prefix or a range consisting of one IP).
Otherwise we would theoretically accept any valid Net::IP object here.
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Hannes Duerr <h.duerr@proxmox.com>
Link: https://lore.proxmox.com/20250307125056.169575-3-s.hanreich@proxmox.com
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
| -rw-r--r-- | src/PVE/Network/SDN/SubnetPlugin.pm | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/PVE/Network/SDN/SubnetPlugin.pm b/src/PVE/Network/SDN/SubnetPlugin.pm index 107e2f7..81adc88 100644 --- a/src/PVE/Network/SDN/SubnetPlugin.pm +++ b/src/PVE/Network/SDN/SubnetPlugin.pm @@ -88,9 +88,13 @@ sub validate_dhcp_ranges { my $start_ip = Net::IP->new($dhcp_start); raise_param_exc({ 'dhcp-range' => "start-address is not a valid IP $dhcp_start" }) if !$start_ip; + raise_param_exc({ 'dhcp-range' => "start-address must be a singular IP" }) if $start_ip->size() != 1; + $dhcp_range->{'start-address'} = $start_ip->ip(); my $end_ip = Net::IP->new($dhcp_end); raise_param_exc({ 'dhcp-range' => "end-address is not a valid IP $dhcp_end" }) if !$end_ip; + raise_param_exc({ 'dhcp-range' => "end-address must be a singular IP" }) if $end_ip->size() != 1; + $dhcp_range->{'end-address'} = $end_ip->ip(); if ($start_ip->bincomp('gt', $end_ip)) { raise_param_exc({ 'dhcp-range' => "start-address $dhcp_start must be smaller than end-address $dhcp_end" }) |
