[pve-devel] [PATCH] Modified pve_verify_ipv4mask
Dietmar Maurer
dietmar at proxmox.com
Fri Feb 22 09:22:33 CET 2013
Hi Damien,
many thanks for the patch!
Using a regex for that purpose is a bit slow, so I committed a slightly modified version
using a hash lookup table (there are only 30 valid masks).
see: https://git.proxmox.com/?p=pve-common.git;a=commit;h=a13c6f08a36cd499fe9eb5a2aa7333ef5ff9bb92
> -----Original Message-----
> From: pve-devel-bounces at pve.proxmox.com [mailto:pve-devel-
> bounces at pve.proxmox.com] On Behalf Of Damien PIQUET
> Sent: Donnerstag, 21. Februar 2013 20:30
> To: pve-devel at pve.proxmox.com
> Subject: [pve-devel] [PATCH] Modified pve_verify_ipv4mask
>
> 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
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
More information about the pve-devel
mailing list