0
0
Fork 0

nsd/ssl: Fix Resolve/ResolveEx and stub GetConnectionCount (#2208)

This commit is contained in:
Ac_K 2021-04-14 14:47:19 +02:00 committed by GitHub
parent 6cb22c9d38
commit 9575a7638a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 5 deletions

View file

@ -1,4 +1,5 @@
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
using Ryujinx.Cpu;
using Ryujinx.HLE.Exceptions; using Ryujinx.HLE.Exceptions;
using Ryujinx.HLE.HOS.Services.Settings; using Ryujinx.HLE.HOS.Services.Settings;
using Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager; using Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager;
@ -135,9 +136,16 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd
long outputPosition = context.Request.ReceiveBuff[0].Position; long outputPosition = context.Request.ReceiveBuff[0].Position;
long outputSize = context.Request.ReceiveBuff[0].Size; long outputSize = context.Request.ReceiveBuff[0].Size;
ResultCode result = _fqdnResolver.ResolveEx(context, out ResultCode errorCode, out string resolvedAddress); ResultCode result = _fqdnResolver.ResolveEx(context, out _, out string resolvedAddress);
byte[] resolvedAddressBuffer = Encoding.UTF8.GetBytes(resolvedAddress + '\0'); if (resolvedAddress.Length > outputSize)
{
return ResultCode.InvalidArgument;
}
byte[] resolvedAddressBuffer = Encoding.UTF8.GetBytes(resolvedAddress);
MemoryHelper.FillWithZeros(context.Memory, outputPosition, (int)outputSize);
context.Memory.Write((ulong)outputPosition, resolvedAddressBuffer); context.Memory.Write((ulong)outputPosition, resolvedAddressBuffer);
@ -153,7 +161,14 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd
ResultCode result = _fqdnResolver.ResolveEx(context, out ResultCode errorCode, out string resolvedAddress); ResultCode result = _fqdnResolver.ResolveEx(context, out ResultCode errorCode, out string resolvedAddress);
byte[] resolvedAddressBuffer = Encoding.UTF8.GetBytes(resolvedAddress + '\0'); if (resolvedAddress.Length > outputSize)
{
return ResultCode.InvalidArgument;
}
byte[] resolvedAddressBuffer = Encoding.UTF8.GetBytes(resolvedAddress);
MemoryHelper.FillWithZeros(context.Memory, outputPosition, (int)outputSize);
context.Memory.Write((ulong)outputPosition, resolvedAddressBuffer); context.Memory.Write((ulong)outputPosition, resolvedAddressBuffer);

View file

@ -104,7 +104,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager
context.Memory.Read((ulong)inputPosition, addressBuffer); context.Memory.Read((ulong)inputPosition, addressBuffer);
string address = Encoding.UTF8.GetString(addressBuffer); string address = Encoding.UTF8.GetString(addressBuffer).TrimEnd('\0');
resultCode = Resolve(context, address, out resolvedAddress); resultCode = Resolve(context, address, out resolvedAddress);

View file

@ -78,7 +78,12 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService
long inputDataPosition = context.Request.SendBuff[0].Position; long inputDataPosition = context.Request.SendBuff[0].Position;
long inputDataSize = context.Request.SendBuff[0].Size; long inputDataSize = context.Request.SendBuff[0].Size;
uint transferredSize = 0; byte[] data = new byte[inputDataSize];
context.Memory.Read((ulong)inputDataPosition, data);
// NOTE: Tell the guest everything is transferred.
uint transferredSize = (uint)inputDataSize;
context.ResponseData.Write(transferredSize); context.ResponseData.Write(transferredSize);

View file

@ -6,6 +6,8 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService
{ {
class ISslContext : IpcService class ISslContext : IpcService
{ {
private uint _connectionCount;
private ulong _serverCertificateId; private ulong _serverCertificateId;
private ulong _clientCertificateId; private ulong _clientCertificateId;
@ -17,6 +19,19 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService
{ {
MakeObject(context, new ISslConnection()); MakeObject(context, new ISslConnection());
_connectionCount++;
return ResultCode.Success;
}
[CommandHipc(3)]
// GetConnectionCount() -> u32 count
public ResultCode GetConnectionCount(ServiceCtx context)
{
context.ResponseData.Write(_connectionCount);
Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { _connectionCount });
return ResultCode.Success; return ResultCode.Success;
} }