[pve-devel] [PATCH] Modified pve_verify_ipv4mask

Damien PIQUET piqudam at gmail.com
Thu Feb 21 20:30:03 CET 2013


fixed class A validation failure
Improved validation filtering

see https://bugzilla.proxmox.com/show_bug.cgi?id=335 for details

Signed-off-by: Damien PIQUET <piqudam at gmail.com>
---
 data/PVE/JSONSchema.pm |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/data/PVE/JSONSchema.pm b/data/PVE/JSONSchema.pm
index dbaffa5..3a5a7a1 100644
--- a/data/PVE/JSONSchema.pm
+++ b/data/PVE/JSONSchema.pm
@@ -153,8 +153,11 @@ register_format('ipv4mask', \&pve_verify_ipv4mask);
 sub pve_verify_ipv4mask {
     my ($mask, $noerr) = @_;
 
-    if ($mask !~ m/^255\.255\.(\d{1,3})\.(\d{1,3})$/ ||
-	!(($1 <= 255) && ($2 <= 255)))  {
+    my $maskre = '(0|128|192|224|240|248|252|254|255)';
+    my $fbytere = '(128|192|224|240|248|252|254|255)';
+    my $lbytere = '(0|128|192|224|240|248|252)';
+
+    if ($mask !~ m/^${fbytere}\.${maskre}\.${maskre}\.${lbytere}$/) {
 	return undef if $noerr;
 	die "value does not look like a valid IP netmask\n";
     }
-- 
1.7.10.4




More information about the pve-devel mailing list