diff options
author | Vincent Petry <vincent@nextcloud.com> | 2021-11-22 14:01:41 +0100 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2021-11-23 10:28:20 +0000 |
commit | 87af149292d3b377845664bf170b923042b53295 (patch) | |
tree | 868a508d77f00b82e25df6b6f121fe3ebb13a004 | |
parent | fb701e344ec35766a791dd451621404dbe2046da (diff) | |
download | nextcloud-server-87af149292d3b377845664bf170b923042b53295.tar.gz nextcloud-server-87af149292d3b377845664bf170b923042b53295.zip |
Fix getting subnet of ipv4 mapped ipv6 addresses
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
-rw-r--r-- | lib/private/Security/Normalizer/IpAddress.php | 2 | ||||
-rw-r--r-- | tests/lib/Security/Normalizer/IpAddressTest.php | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/lib/private/Security/Normalizer/IpAddress.php b/lib/private/Security/Normalizer/IpAddress.php index 0a3606de28a..f878c9f986b 100644 --- a/lib/private/Security/Normalizer/IpAddress.php +++ b/lib/private/Security/Normalizer/IpAddress.php @@ -103,6 +103,8 @@ class IpAddress { $this->ip, 32 ); + } elseif (substr(strtolower($this->ip), 0, 7) === '::ffff:') { + return '::ffff:' . $this->getIPv4Subnet(substr($this->ip, 7), 32); } return $this->getIPv6Subnet( $this->ip, diff --git a/tests/lib/Security/Normalizer/IpAddressTest.php b/tests/lib/Security/Normalizer/IpAddressTest.php index 044fc52b4b9..a3c839adc3b 100644 --- a/tests/lib/Security/Normalizer/IpAddressTest.php +++ b/tests/lib/Security/Normalizer/IpAddressTest.php @@ -36,6 +36,10 @@ class IpAddressTest extends TestCase { '192.168.0.123/32', ], [ + '::ffff:192.168.0.123', + '::ffff:192.168.0.123/32', + ], + [ '2001:0db8:85a3:0000:0000:8a2e:0370:7334', '2001:db8:85a3::/64', ], |