From 39f23fde767d0fd2d66e8d300de94f9761f9c977 Mon Sep 17 00:00:00 2001 From: RD WebDesign Date: Thu, 20 Oct 2022 02:35:55 -0300 Subject: [PATCH] Avoid cname loops Signed-off-by: RD WebDesign --- scripts/pi-hole/php/func.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/pi-hole/php/func.php b/scripts/pi-hole/php/func.php index ea2f60a71..3d8c450b7 100644 --- a/scripts/pi-hole/php/func.php +++ b/scripts/pi-hole/php/func.php @@ -392,12 +392,17 @@ function addCustomCNAMEEntry($domain = '', $target = '', $reload = '', $json = t return returnError('Target must be valid', $json); } - // Check if each submitted domain is valid $domains = array_map('trim', explode(',', $domain)); foreach ($domains as $d) { + // Check if each submitted domain is valid if (!validDomain($d)) { return returnError("Domain '{$d}' is not valid", $json); } + + // Check if each submitted domain is different than the target to avoid loops + if (strtolower($d) === strtolower($target)) { + return returnError('Domain and target cannot be the same', $json); + } } $existingEntries = getCustomCNAMEEntries();