From: Tim Düsterhus Date: Tue, 20 Jul 2021 10:43:38 +0000 (+0200) Subject: Default IP address to `::` if `$_SERVER['REMOTE_ADDR']` is unavailable X-Git-Tag: 5.4.2~24 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e0de0021e27994ecf45029a65a872e82df6ce9bc;p=GitHub%2FWoltLab%2FWCF.git 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. --- 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']; }