Attaching patch file.

On 03/07/2012 05:10 PM, Petr Vobornik wrote:
Network validator allowed invalid mask format:
* leading zeros: 192.168.0.1/0024
* trailing chars: 192.168.0.1/24abcd

It was fixed.

https://fedorahosted.org/freeipa/ticket/2493

--
Petr Vobornik
From bdc47a1f588a0e406c66467fae53642c6123214b Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Wed, 7 Mar 2012 14:43:43 +0100
Subject: [PATCH] Fixed mask validation in network_validator

Network validator allowed invalid mask format:
 * leading zeros: 192.168.0.1/0024
 * trailing chars: 192.168.0.1/24abcd

It was fixed.

https://fedorahosted.org/freeipa/ticket/2493
---
 install/ui/dns.js |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/install/ui/dns.js b/install/ui/dns.js
index 4212f1d2446eff0d29e0b57225339e79765017fc..33b21e4cfb315b1fde9a47f9b44dcbfded89015d 100644
--- a/install/ui/dns.js
+++ b/install/ui/dns.js
@@ -2273,7 +2273,7 @@ IPA.network_validator = function(spec) {
             return that.true_result();
         }
 
-        var address_part, mask_part;
+        var address_part, mask;
 
         if (value.indexOf('/') > -1) {
 
@@ -2281,9 +2281,9 @@ IPA.network_validator = function(spec) {
 
             if (parts.length === 2) {
                 address_part = parts[0];
-                mask_part = parts[1];
+                mask = parts[1];
 
-                if (mask_part === '') return that.false_result();
+                if (mask === '') return that.false_result();
 
             } else {
                 return that.false_result();
@@ -2302,14 +2302,12 @@ IPA.network_validator = function(spec) {
         var address = NET.ip_address(address_part);
         if (!address.valid) return that.false_result();
 
-        if (mask_part) {
-
-            var mask = parseInt(mask_part, 10);
+        if (mask) {
 
             var mask_length = 32;
             if (address.type === 'v6') mask_length = 128;
 
-            if (isNaN(mask) || mask < 8 || mask > mask_length) {
+            if (!mask.match(/^[1-9]\d*$/) || mask < 8 || mask > mask_length) {
                 return that.false_result();
             }
         }
-- 
1.7.7.6

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to