yuzu-emu
/
yuzu
Archived
1
0
Fork 0

sfdnsres: ensure lp1 is not resolved

This commit is contained in:
Liam 2023-08-28 11:48:25 -04:00
parent ada4697300
commit 6c68b07a67
2 changed files with 21 additions and 2 deletions

View File

@ -19,6 +19,12 @@ enum class ServerEnvironmentType : u8 {
Dp, Dp,
}; };
// This is nn::nsd::EnvironmentIdentifier
struct EnvironmentIdentifier {
std::array<u8, 8> identifier;
};
static_assert(sizeof(EnvironmentIdentifier) == 0x8);
NSD::NSD(Core::System& system_, const char* name) : ServiceFramework{system_, name} { NSD::NSD(Core::System& system_, const char* name) : ServiceFramework{system_, name} {
// clang-format off // clang-format off
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
@ -101,8 +107,9 @@ void NSD::ResolveEx(HLERequestContext& ctx) {
} }
void NSD::GetEnvironmentIdentifier(HLERequestContext& ctx) { void NSD::GetEnvironmentIdentifier(HLERequestContext& ctx) {
const std::string environment_identifier = "lp1"; constexpr EnvironmentIdentifier lp1 = {
ctx.WriteBuffer(environment_identifier); .identifier = {'l', 'p', '1', '\0', '\0', '\0', '\0', '\0'}};
ctx.WriteBuffer(lp1);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);

View File

@ -150,6 +150,12 @@ static std::pair<u32, GetAddrInfoError> GetHostByNameRequestImpl(HLERequestConte
const std::string host = Common::StringFromBuffer(host_buffer); const std::string host = Common::StringFromBuffer(host_buffer);
// For now, ignore options, which are in input buffer 1 for GetHostByNameRequestWithOptions. // For now, ignore options, which are in input buffer 1 for GetHostByNameRequestWithOptions.
// Prevent resolution of Nintendo servers
if (host.find("srv.nintendo.net") != std::string::npos) {
LOG_WARNING(Network, "Resolution of hostname {} requested, returning EAI_AGAIN", host);
return {0, GetAddrInfoError::AGAIN};
}
auto res = Network::GetAddressInfo(host, /*service*/ std::nullopt); auto res = Network::GetAddressInfo(host, /*service*/ std::nullopt);
if (!res.has_value()) { if (!res.has_value()) {
return {0, Translate(res.error())}; return {0, Translate(res.error())};
@ -261,6 +267,12 @@ static std::pair<u32, GetAddrInfoError> GetAddrInfoRequestImpl(HLERequestContext
const auto host_buffer = ctx.ReadBuffer(0); const auto host_buffer = ctx.ReadBuffer(0);
const std::string host = Common::StringFromBuffer(host_buffer); const std::string host = Common::StringFromBuffer(host_buffer);
// Prevent resolution of Nintendo servers
if (host.find("srv.nintendo.net") != std::string::npos) {
LOG_WARNING(Network, "Resolution of hostname {} requested, returning EAI_AGAIN", host);
return {0, GetAddrInfoError::AGAIN};
}
std::optional<std::string> service = std::nullopt; std::optional<std::string> service = std::nullopt;
if (ctx.CanReadBuffer(1)) { if (ctx.CanReadBuffer(1)) {
const std::span<const u8> service_buffer = ctx.ReadBuffer(1); const std::span<const u8> service_buffer = ctx.ReadBuffer(1);