From 1af78416d1678fdb4d0942d8c56f56e36d345d8f Mon Sep 17 00:00:00 2001 From: gdkchan Date: Thu, 26 Apr 2018 11:34:40 -0300 Subject: [PATCH] Add null terminator to audio device names when writing to the output buffer --- Ryujinx.Core/OsHle/Services/Aud/IAudioDevice.cs | 6 +++--- Ryujinx.Core/OsHle/Services/Aud/IAudioOutManager.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Ryujinx.Core/OsHle/Services/Aud/IAudioDevice.cs b/Ryujinx.Core/OsHle/Services/Aud/IAudioDevice.cs index 8ce86a0bcf..1eb61d29f5 100644 --- a/Ryujinx.Core/OsHle/Services/Aud/IAudioDevice.cs +++ b/Ryujinx.Core/OsHle/Services/Aud/IAudioDevice.cs @@ -45,7 +45,7 @@ namespace Ryujinx.Core.OsHle.Services.Aud foreach (string Name in DeviceNames) { - byte[] Buffer = Encoding.UTF8.GetBytes(Name + '\0'); + byte[] Buffer = Encoding.ASCII.GetBytes(Name + "\0"); if ((Position - BasePosition) + Buffer.Length > Size) { @@ -71,7 +71,7 @@ namespace Ryujinx.Core.OsHle.Services.Aud byte[] DeviceNameBuffer = AMemoryHelper.ReadBytes(Context.Memory, Position, Size); - string DeviceName = Encoding.UTF8.GetString(DeviceNameBuffer); + string DeviceName = Encoding.ASCII.GetString(DeviceNameBuffer); Context.Ns.Log.PrintStub(LogClass.ServiceAudio, "Stubbed."); @@ -85,7 +85,7 @@ namespace Ryujinx.Core.OsHle.Services.Aud long Position = Context.Request.ReceiveBuff[0].Position; long Size = Context.Request.ReceiveBuff[0].Size; - byte[] DeviceNameBuffer = Encoding.UTF8.GetBytes(Name + '\0'); + byte[] DeviceNameBuffer = Encoding.ASCII.GetBytes(Name + "\0"); if ((ulong)DeviceNameBuffer.Length <= (ulong)Size) { diff --git a/Ryujinx.Core/OsHle/Services/Aud/IAudioOutManager.cs b/Ryujinx.Core/OsHle/Services/Aud/IAudioOutManager.cs index 3bf154f362..d9484a9585 100644 --- a/Ryujinx.Core/OsHle/Services/Aud/IAudioOutManager.cs +++ b/Ryujinx.Core/OsHle/Services/Aud/IAudioOutManager.cs @@ -32,7 +32,7 @@ namespace Ryujinx.Core.OsHle.Services.Aud int NameCount = 0; - byte[] DeviceNameBuffer = Encoding.UTF8.GetBytes(DefaultAudioOutput); + byte[] DeviceNameBuffer = Encoding.ASCII.GetBytes(DefaultAudioOutput + "\0"); if ((ulong)DeviceNameBuffer.Length <= (ulong)Size) { @@ -67,7 +67,7 @@ namespace Ryujinx.Core.OsHle.Services.Aud long Position = Context.Request.ReceiveBuff[0].Position; long Size = Context.Request.ReceiveBuff[0].Size; - byte[] DeviceNameBuffer = Encoding.UTF8.GetBytes(DeviceName); + byte[] DeviceNameBuffer = Encoding.ASCII.GetBytes(DeviceName + "\0"); if ((ulong)DeviceNameBuffer.Length <= (ulong)Size) {