Validate IP addresses
authorJamie Cameron <jcameron@webmin.com>
Mon, 4 May 2009 19:08:45 +0000 (19:08 +0000)
committerJamie Cameron <jcameron@webmin.com>
Mon, 4 May 2009 19:08:45 +0000 (19:08 +0000)
dhcpd/lang/en
dhcpd/save_options.cgi

index e59a9b2..541afbe 100644 (file)
@@ -186,6 +186,7 @@ sopt_edname='$1' is not a valid option name
 sopt_ednum='$1' is not a valid option number
 sopt_edtype='$1' is not a valid option type
 sopt_ecval=Missing value for custom option '$1'
+sopt_ecip=Value for custom option '$1' must be an IP address
 
 sshared_faildel=Failed to delete shared network
 sshared_failsave=Failed to save shared network
index 3e9efe7..3ca8ae4 100755 (executable)
@@ -135,6 +135,11 @@ if ($config{'dhcpd_version'} >= 3) {
                local $o = $optdef{$in{"cname_$i"}};
                local $cv = $in{"cval_$i"};
                $cv =~ /\S/ || &error(&text('sopt_ecval', $in{"cname_$i"}));
+               if ($o && $o->{'values'}->[4] eq 'ip-address') {
+                       &check_ipaddress($cv) ||
+                         &check_ip6address($cv) ||
+                           &error(&text('sopt_ecip', $in{"cname_$i"}));
+                       }
                if ($o && $o->{'values'}->[4] eq 'string' ||
                    $cv !~ /^([0-9a-fA-F]{1,2}:)*[0-9a-fA-F]{1,2}$/ &&
                    !&check_ipaddress($cv)) {