From e0de0021e27994ecf45029a65a872e82df6ce9bc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 20 Jul 2021 12:43:38 +0200 Subject: [PATCH] Default IP address to `::` if `$_SERVER['REMOTE_ADDR']` is unavailable The session list within the AccountSecurityPage relies on all sessions storing valid IP addresses. When using `cli.php` no `REMOTE_ADDR` will be available and an empty string was being stored. As the empty string is not a valid IP address the `\wcf\util\IpAddress` class errored out. Fix this issue by always returning a syntactically valid IP address from `UserUtil::getIpAddress()`. `::` is being used which is commonly used to indicate unknown IP addresses and must never appear within valid IP packets. --- wcfsetup/install/files/lib/util/UserUtil.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/util/UserUtil.class.php b/wcfsetup/install/files/lib/util/UserUtil.class.php index 5bb6ca56d2..9d1b774ec9 100644 --- a/wcfsetup/install/files/lib/util/UserUtil.class.php +++ b/wcfsetup/install/files/lib/util/UserUtil.class.php @@ -145,8 +145,8 @@ final class UserUtil */ public static function getIpAddress() { - $REMOTE_ADDR = ''; - if (isset($_SERVER['REMOTE_ADDR'])) { + $REMOTE_ADDR = '::'; + if (!empty($_SERVER['REMOTE_ADDR'])) { $REMOTE_ADDR = $_SERVER['REMOTE_ADDR']; } -- 2.20.1