forked from Mirror/Ryujinx
sfdnsres; Fix deserializer of AddrInfoSerialized when addresses are empty (#3924)
This commit is contained in:
parent
1865ea87e5
commit
472119c8da
3 changed files with 13 additions and 5 deletions
|
@ -566,7 +566,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
|
||||||
|
|
||||||
private static List<AddrInfoSerialized> DeserializeAddrInfos(IVirtualMemoryManager memory, ulong address, ulong size)
|
private static List<AddrInfoSerialized> DeserializeAddrInfos(IVirtualMemoryManager memory, ulong address, ulong size)
|
||||||
{
|
{
|
||||||
List<AddrInfoSerialized> result = new List<AddrInfoSerialized>();
|
List<AddrInfoSerialized> result = new();
|
||||||
|
|
||||||
ReadOnlySpan<byte> data = memory.GetSpan(address, (int)size);
|
ReadOnlySpan<byte> data = memory.GetSpan(address, (int)size);
|
||||||
|
|
||||||
|
@ -606,9 +606,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: 0 = Any
|
// NOTE: 0 = Any
|
||||||
AddrInfoSerializedHeader header = new AddrInfoSerializedHeader(ip, 0);
|
AddrInfoSerializedHeader header = new(ip, 0);
|
||||||
AddrInfo4 addr = new AddrInfo4(ip, (short)port);
|
AddrInfo4 addr = new(ip, (short)port);
|
||||||
AddrInfoSerialized info = new AddrInfoSerialized(header, addr, null, hostEntry.HostName);
|
AddrInfoSerialized info = new(header, addr, null, hostEntry.HostName);
|
||||||
|
|
||||||
data = info.Write(data);
|
data = info.Write(data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Types
|
||||||
public byte Family;
|
public byte Family;
|
||||||
public short Port;
|
public short Port;
|
||||||
public Array4<byte> Address;
|
public Array4<byte> Address;
|
||||||
|
public Array8<byte> Padding;
|
||||||
|
|
||||||
public AddrInfo4(IPAddress address, short port)
|
public AddrInfo4(IPAddress address, short port)
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Types
|
||||||
|
|
||||||
AddrInfo4? socketAddress = null;
|
AddrInfo4? socketAddress = null;
|
||||||
Array4<byte>? rawIPv4Address = null;
|
Array4<byte>? rawIPv4Address = null;
|
||||||
string canonicalName = null;
|
string canonicalName;
|
||||||
|
|
||||||
buffer = buffer[Unsafe.SizeOf<AddrInfoSerializedHeader>()..];
|
buffer = buffer[Unsafe.SizeOf<AddrInfoSerializedHeader>()..];
|
||||||
|
|
||||||
|
@ -50,6 +50,13 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Types
|
||||||
|
|
||||||
Debug.Assert(header.Magic == SfdnsresContants.AddrInfoMagic);
|
Debug.Assert(header.Magic == SfdnsresContants.AddrInfoMagic);
|
||||||
|
|
||||||
|
if (header.AddressLength == 0)
|
||||||
|
{
|
||||||
|
rest = buffer;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (header.Family == (int)AddressFamily.InterNetwork)
|
if (header.Family == (int)AddressFamily.InterNetwork)
|
||||||
{
|
{
|
||||||
socketAddress = MemoryMarshal.Read<AddrInfo4>(buffer);
|
socketAddress = MemoryMarshal.Read<AddrInfo4>(buffer);
|
||||||
|
|
Loading…
Reference in a new issue