Skip to content
Snippets Groups Projects
Commit 8299492d authored by Georg Ringer's avatar Georg Ringer Committed by Benni Mack
Browse files

[BUGFIX] Check return value of inet_pton in IpAnonymizationUtility

The method inet_pton returns false if the provided IP address is
invalid. This needs to be checked to avoid errors.

Resolves: #90059
Releases: master, 9.5, 8.7
Change-Id: Ic3c7955eb64aff723b31862ef9c7c95e31a098b7
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62833


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
parent 9eb1aa97
Branches
Tags
No related merge requests found
......@@ -72,7 +72,10 @@ class IpAnonymizationUtility
return '';
}
$packedAddress = inet_pton($address);
$packedAddress = @inet_pton($address);
if ($packedAddress === false) {
return '';
}
$length = strlen($packedAddress);
if ($length === 4) {
......
......@@ -43,6 +43,8 @@ class IpAnonymizationUtilityTest extends UnitTestCase
'IPv6 address with fallback' => ['2002:6dcd:8c74:6501:fb2:61c:ac98:6bea', null, '2002:6dcd:8c74:6501::'],
'IPv4-Embedded IPv6 Address' => ['::ffff:18.52.86.120', 1, '::'],
'anonymized IPv4 address' => ['192.158.0.0', 1, '192.158.0.0'],
'invalid IPv4 address given' => ['127.0.01', 1, ''],
'invalid IPv6 address given' => ['ffff18.52.86.120', 1, ''],
];
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment