]> git.proxmox.com Git - pve-common.git/commitdiff
Modified IPv4 validation function, included Net::IP
authorDamien PIQUET <piqudam@gmail.com>
Sat, 23 Feb 2013 11:21:09 +0000 (12:21 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 25 Feb 2013 05:21:13 +0000 (06:21 +0100)
Signed-off-by: Damien PIQUET <piqudam@gmail.com>
data/PVE/JSONSchema.pm

index 4b3364635469013e009e75208427147145702482..6866f18a3030d973e33e4f704d1947a30ba1fd16 100644 (file)
@@ -8,6 +8,7 @@ use Devel::Cycle -quiet; # todo: remove?
 use PVE::Tools qw(split_list);
 use PVE::Exception qw(raise);
 use HTTP::Status qw(:constants);
+use Net::IP qw(:PROC);
 
 use base 'Exporter';
 
@@ -140,11 +141,8 @@ register_format('ipv4', \&pve_verify_ipv4);
 sub pve_verify_ipv4 {
     my ($ipv4, $noerr) = @_;
 
-   if ($ipv4 !~ m/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ ||
-       !(($1 > 0) && ($1 < 255) &&
-        ($2 <= 255) && ($3 <= 255) && 
-        ($4 > 0) && ($4 < 255)))  {
-          return undef if $noerr;
+    if (!Net::IP::ip_is_ipv4($ipv4))  {
+       return undef if $noerr;
        die "value does not look like a valid IP address\n";
     }
     return $ipv4;