]> git.gsnw.org Git - m0n0chwall.git/commitdiff
Add safety for the unlikely situation where system uses more then 9899 rules: Impleme...
authorjdegraeve <jdegraeve@e36fee2c-cc09-0410-a7cc-ebac5c6737de>
Wed, 29 Mar 2006 22:29:59 +0000 (22:29 +0000)
committerjdegraeve <jdegraeve@e36fee2c-cc09-0410-a7cc-ebac5c6737de>
Wed, 29 Mar 2006 22:29:59 +0000 (22:29 +0000)
git-svn-id: https://svn.m0n0.ch/wall/trunk@119 e36fee2c-cc09-0410-a7cc-ebac5c6737de

phpconf/inc/captiveportal.inc

index 70acace967338b2c33ba8dad88fb5925e44a785a..824948d322fc32ab08f18818d1712f5fe2c74d20 100644 (file)
@@ -892,7 +892,7 @@ function captiveportal_write_elements() {
  *
  */
 
-function captiveportal_get_next_ipfw_ruleno($rulenos_start = 10000) {
+function captiveportal_get_next_ipfw_ruleno($rulenos_start = 10000, $rulenos_range_max = 9899) {
 
     exec("/sbin/ipfw show", $fwrules);
     foreach ($fwrules as $fwrule) {
@@ -900,7 +900,11 @@ function captiveportal_get_next_ipfw_ruleno($rulenos_start = 10000) {
         $rulenos_used[] = $matches[1];
     }
     $rulenos_used = array_unique($rulenos_used);
-    $rulenos_pool = range($rulenos_start, ($rulenos_start + count($rulenos_used)));
+    $rulenos_range = count($rulenos_used);
+    if ($rulenos_range > $rulenos_range_max) {
+        return NULL;
+    }
+    $rulenos_pool = range($rulenos_start, ($rulenos_start + $rulenos_range));
     $rulenos_free = array_diff($rulenos_pool, $rulenos_used);
     $ruleno = array_shift($rulenos_free);