mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-05-22 05:05:47 +00:00
Structural and Memory Safety Improvements, Analyzer Cleanup (ryubing/ryujinx!47)
See merge request ryubing/ryujinx!47
This commit is contained in:
@@ -7,7 +7,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -19,9 +18,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
|
||||
// TODO: Determine where and how NetworkServiceAccountId is set.
|
||||
private const long NetworkServiceAccountId = 0xcafe;
|
||||
|
||||
#pragma warning disable IDE0052 // Remove unread private member
|
||||
private readonly UserId _userId;
|
||||
#pragma warning restore IDE0052
|
||||
|
||||
private byte[] _cachedTokenData;
|
||||
private DateTime _cachedTokenExpiry;
|
||||
@@ -128,9 +125,8 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
|
||||
public ResultCode LoadIdTokenCache(ServiceCtx context)
|
||||
{
|
||||
ulong bufferPosition = context.Request.ReceiveBuff[0].Position;
|
||||
#pragma warning disable IDE0059 // Remove unnecessary value assignment
|
||||
|
||||
ulong bufferSize = context.Request.ReceiveBuff[0].Size;
|
||||
#pragma warning restore IDE0059
|
||||
|
||||
// NOTE: This opens the file at "su/cache/USERID_IN_UUID_STRING.dat" (where USERID_IN_UUID_STRING is formatted as "%08x-%04x-%04x-%02x%02x-%08x%04x")
|
||||
// in the "account:/" savedata and writes some data in the buffer.
|
||||
@@ -156,6 +152,11 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
|
||||
|
||||
byte[] tokenData = _cachedTokenData;
|
||||
|
||||
if ((ulong)tokenData.Length > bufferSize)
|
||||
{
|
||||
return ResultCode.InvalidIdTokenCacheBufferSize;
|
||||
}
|
||||
|
||||
context.Memory.Write(bufferPosition, tokenData);
|
||||
context.ResponseData.Write(tokenData.Length);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public readonly record struct UserId
|
||||
{
|
||||
public readonly long High;
|
||||
|
||||
Reference in New Issue
Block a user