From 4864648e727c6f526e3b65478f222c15468f6074 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sat, 8 Jan 2022 20:18:09 -0300 Subject: [PATCH] Return error on DNS resolution when guest internet access is disabled (#2983) * Return error on DNS resolution when guest internet access is disabled * Log DNS lookup calls --- .../Services/Sockets/Sfdnsres/IResolver.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs b/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs index 32346dc7..a07fc518 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs @@ -245,6 +245,15 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres { string host = MemoryHelper.ReadAsciiString(context.Memory, inputBufferPosition, (int)inputBufferSize); + if (!context.Device.Configuration.EnableInternetAccess) + { + Logger.Info?.Print(LogClass.ServiceSfdnsres, $"Guest network access disabled, DNS Blocked: {host}"); + + WriteResponse(context, withOptions, 0, GaiError.NoData, NetDbError.HostNotFound); + + return ResultCode.Success; + } + // TODO: Use params. bool enableNsdResolve = (context.RequestData.ReadInt32() & 1) != 0; int timeOut = context.RequestData.ReadInt32(); @@ -331,6 +340,15 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres ulong optionsBufferPosition, ulong optionsBufferSize) { + if (!context.Device.Configuration.EnableInternetAccess) + { + Logger.Info?.Print(LogClass.ServiceSfdnsres, $"Guest network access disabled, DNS Blocked."); + + WriteResponse(context, withOptions, 0, GaiError.NoData, NetDbError.HostNotFound); + + return ResultCode.Success; + } + byte[] rawIp = new byte[inputBufferSize]; context.Memory.Read(inputBufferPosition, rawIp); @@ -442,6 +460,15 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres string host = MemoryHelper.ReadAsciiString(context.Memory, context.Request.SendBuff[0].Position, (long)context.Request.SendBuff[0].Size); string service = MemoryHelper.ReadAsciiString(context.Memory, context.Request.SendBuff[1].Position, (long)context.Request.SendBuff[1].Size); + if (!context.Device.Configuration.EnableInternetAccess) + { + Logger.Info?.Print(LogClass.ServiceSfdnsres, $"Guest network access disabled, DNS Blocked: {host}"); + + WriteResponse(context, withOptions, 0, GaiError.NoData, NetDbError.HostNotFound); + + return ResultCode.Success; + } + // NOTE: We ignore hints for now. DeserializeAddrInfos(context.Memory, (ulong)context.Request.SendBuff[2].Position, (ulong)context.Request.SendBuff[2].Size);