From d7827d4e0fd807d21ad40fa629479fcbadb856f0 Mon Sep 17 00:00:00 2001 From: Robin Winkelewski Date: Tue, 18 Apr 2023 01:28:52 +0200 Subject: [PATCH] Fix: Filter out empty IP addresses in dnsResolve method This commit resolves an issue where empty IP addresses could be returned by the dnsResolve method due to CNAME recursion. The fix filters out empty IP addresses before returning the result, ensuring that only valid, non-empty IP addresses are used in the addDnsPinning method. Signed-off-by: Robin Winkelewski --- lib/private/Http/Client/DnsPinMiddleware.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/private/Http/Client/DnsPinMiddleware.php b/lib/private/Http/Client/DnsPinMiddleware.php index c6a58972fdd65..c81548a2b40da 100644 --- a/lib/private/Http/Client/DnsPinMiddleware.php +++ b/lib/private/Http/Client/DnsPinMiddleware.php @@ -101,7 +101,10 @@ private function dnsResolve(string $target, int $recursionCount) : array { } } - return $targetIps; + // Filter out empty IP addresses before returning the result + return array_filter($targetIps, function ($ip) { + return !empty($ip); + }); } public function addDnsPinning() {