Skip to content

Commit e60e323

Browse files
susnuxbackportbot[bot]
authored andcommitted
fix(32bit): use PHP_INT_MAX where needed
* Typo from #52392 `0xFFFF` is only 2 bytes, but we need either `0xFFFFFFFF` or maybe a bit easier to read `PHP_INT_MAX`. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 00639fa commit e60e323

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/private/Security/Normalizer/IpAddress.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,15 @@ private function getIPv6Subnet(string $ip): string {
4242
$maskSize = min(64, $config->getSystemValueInt('security.ipv6_normalized_subnet_size', 56));
4343
$maskSize = max(32, $maskSize);
4444
if (PHP_INT_SIZE === 4) {
45+
if ($maskSize === 64) {
46+
$value = -1;
47+
} elseif ($maskSize === 63) {
48+
$value = PHP_INT_MAX;
49+
} else {
50+
$value = (1 << $maskSize - 32) - 1;
51+
}
4552
// as long as we support 32bit PHP we cannot use the `P` pack formatter (and not overflow 32bit integer)
46-
$mask = pack('VVVV', 0xFFFF, $maskSize === 64 ? 0xFFFF : ((1 << $maskSize - 32) - 1), 0, 0);
53+
$mask = pack('VVVV', -1, $value, 0, 0);
4754
} else {
4855
$mask = pack('VVP', (1 << 32) - 1, (1 << $maskSize - 32) - 1, 0);
4956
}

0 commit comments

Comments
 (0)