From 46710d9efa3ea7f770a6d82f282c2cea9e02223e Mon Sep 17 00:00:00 2001 From: Timur Sultanov Date: Sun, 27 Mar 2022 17:41:12 +0300 Subject: LookupServer: Use case-insensitive comparison for domain names Some ISPs may MITM DNS requests coming from clients, changing the case of domain name in response. LookupServer will refuse responses from any DNS server in that case. This commit changes the behaviour to perform a case-insensitive equality check. --- Userland/Services/LookupServer/LookupServer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Services/LookupServer/LookupServer.cpp b/Userland/Services/LookupServer/LookupServer.cpp index 5d9335c938..463f1b2782 100644 --- a/Userland/Services/LookupServer/LookupServer.cpp +++ b/Userland/Services/LookupServer/LookupServer.cpp @@ -269,14 +269,14 @@ ErrorOr> LookupServer::lookup(const DNSName& name, const Strin return Vector {}; } - // Verify the questions in our request and in their response match exactly, including case. + // Verify the questions in our request and in their response match, ignoring case. for (size_t i = 0; i < request.question_count(); ++i) { auto& request_question = request.questions()[i]; auto& response_question = response.questions()[i]; - bool exact_match = request_question.class_code() == response_question.class_code() + bool match = request_question.class_code() == response_question.class_code() && request_question.record_type() == response_question.record_type() - && request_question.name().as_string() == response_question.name().as_string(); - if (!exact_match) { + && request_question.name().as_string().equals_ignoring_case(response_question.name().as_string()); + if (!match) { dbgln("Request and response questions do not match"); dbgln(" Request: name=_{}_, type={}, class={}", request_question.name().as_string(), response_question.record_type(), response_question.class_code()); dbgln(" Response: name=_{}_, type={}, class={}", response_question.name().as_string(), response_question.record_type(), response_question.class_code()); -- cgit v1.2.3