From 12dcb3ce5debab7f68b528fb8fee9de236511e2a Mon Sep 17 00:00:00 2001 From: jdegraeve Date: Wed, 29 Mar 2006 22:29:59 +0000 Subject: [PATCH] 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 --- phpconf/inc/captiveportal.inc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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); -- 2.25.1