From 218767ef1f78a6ba2ae62039f3a65d296d361930 Mon Sep 17 00:00:00 2001 From: Jerome Jutteau Date: Tue, 29 Sep 2015 16:43:32 +0200 Subject: [PATCH 1/1] better checks in ip listing Signed-off-by: Jerome Jutteau --- lib/functions.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/functions.php b/lib/functions.php index 83fdaf1..aaa0daf 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -1121,6 +1121,8 @@ get_ip_list_http_forwarded() if (!empty ($_SERVER['HTTP_X_FORWARDED_FOR'])) { $l = explode (',', $_SERVER['HTTP_X_FORWARDED_FOR']); + if ($l === FALSE) + return array(); foreach ($l as $ip) array_push ($ip_list, preg_replace ('/\s+/', '', $ip)); } @@ -1130,7 +1132,10 @@ get_ip_list_http_forwarded() foreach ($l as $ip) { // Separate IP from port - $ip = explode (':', $ip)[0]; + $ipa = explode (':', $ip); + if ($ipa === FALSE) + continue; + $ip = $ipa[0]; array_push ($ip_list, preg_replace ('/\s+/', '', $ip)); } } -- 2.34.1