From 26fb2015186d634c202ca8270ec4f303300bf69b Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 10 May 2021 13:27:14 -0700 Subject: [PATCH] dns.mitm: handle nullptr hostname --- .../ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.cpp b/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.cpp index a15bf5f1c..6cf2cc89f 100644 --- a/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.cpp +++ b/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.cpp @@ -89,6 +89,8 @@ namespace ams::mitm::socket::resolver { LogDebug("[%016lx]: GetHostByNameRequest(%s)\n", this->client_info.program_id.value, hostname); + R_UNLESS(hostname != nullptr, sm::ResultShouldForwardToSession()); + ams::socket::InAddrT redirect_addr = {}; R_UNLESS(GetRedirectedHostByName(std::addressof(redirect_addr), hostname), sm::mitm::ResultShouldForwardToSession()); @@ -107,6 +109,8 @@ namespace ams::mitm::socket::resolver { LogDebug("[%016lx]: GetAddrInfoRequest(%s, %s)\n", this->client_info.program_id.value, reinterpret_cast(node.GetPointer()), reinterpret_cast(srv.GetPointer())); + R_UNLESS(hostname != nullptr, sm::ResultShouldForwardToSession()); + ams::socket::InAddrT redirect_addr = {}; R_UNLESS(GetRedirectedHostByName(std::addressof(redirect_addr), hostname), sm::mitm::ResultShouldForwardToSession()); @@ -142,6 +146,8 @@ namespace ams::mitm::socket::resolver { LogDebug("[%016lx]: GetHostByNameRequestWithOptions(%s)\n", this->client_info.program_id.value, hostname); + R_UNLESS(hostname != nullptr, sm::ResultShouldForwardToSession()); + ams::socket::InAddrT redirect_addr = {}; R_UNLESS(GetRedirectedHostByName(std::addressof(redirect_addr), hostname), sm::mitm::ResultShouldForwardToSession()); @@ -160,6 +166,8 @@ namespace ams::mitm::socket::resolver { LogDebug("[%016lx]: GetAddrInfoRequestWithOptions(%s, %s)\n", this->client_info.program_id.value, hostname, reinterpret_cast(srv.GetPointer())); + R_UNLESS(hostname != nullptr, sm::ResultShouldForwardToSession()); + ams::socket::InAddrT redirect_addr = {}; R_UNLESS(GetRedirectedHostByName(std::addressof(redirect_addr), hostname), sm::mitm::ResultShouldForwardToSession());