From: jdegraeve Date: Wed, 29 Mar 2006 22:29:59 +0000 (+0000) Subject: Add safety for the unlikely situation where system uses more then 9899 rules: Impleme... X-Git-Url: https://git.gsnw.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12dcb3ce5debab7f68b528fb8fee9de236511e2a;p=m0n0chwall.git Add safety for the unlikely situation where system uses more then 9899 rules: Implement boundary for range, called rulenos_range_max git-svn-id: https://svn.m0n0.ch/wall/trunk@119 e36fee2c-cc09-0410-a7cc-ebac5c6737de --- diff --git a/phpconf/inc/captiveportal.inc b/phpconf/inc/captiveportal.inc index 70acace..824948d 100644 --- a/phpconf/inc/captiveportal.inc +++ b/phpconf/inc/captiveportal.inc @@ -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);