aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2025-04-24 11:22:18 +0200
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2025-04-28 19:23:24 +0000
commite60e32388d8cdd1a49e8d49448e5bf1448ba17f1 (patch)
tree44ffd59aaec18ed4f1378887798ae356b6d326ac
parent00639fac4e6d235f85eac1a48766e4d342c7636a (diff)
downloadnextcloud-server-backport/52402/stable31.tar.gz
nextcloud-server-backport/52402/stable31.zip
fix(32bit): use `PHP_INT_MAX` where neededbackport/52402/stable31
* Typo from https://github.com/nextcloud/server/pull/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>
-rw-r--r--lib/private/Security/Normalizer/IpAddress.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/private/Security/Normalizer/IpAddress.php b/lib/private/Security/Normalizer/IpAddress.php
index b3793685a24..4d33a7bd632 100644
--- a/lib/private/Security/Normalizer/IpAddress.php
+++ b/lib/private/Security/Normalizer/IpAddress.php
@@ -42,8 +42,15 @@ class IpAddress {
$maskSize = min(64, $config->getSystemValueInt('security.ipv6_normalized_subnet_size', 56));
$maskSize = max(32, $maskSize);
if (PHP_INT_SIZE === 4) {
+ if ($maskSize === 64) {
+ $value = -1;
+ } elseif ($maskSize === 63) {
+ $value = PHP_INT_MAX;
+ } else {
+ $value = (1 << $maskSize - 32) - 1;
+ }
// as long as we support 32bit PHP we cannot use the `P` pack formatter (and not overflow 32bit integer)
- $mask = pack('VVVV', 0xFFFF, $maskSize === 64 ? 0xFFFF : ((1 << $maskSize - 32) - 1), 0, 0);
+ $mask = pack('VVVV', -1, $value, 0, 0);
} else {
$mask = pack('VVP', (1 << 32) - 1, (1 << $maskSize - 32) - 1, 0);
}