0
0
Fork 0

Add null terminator to audio device names when writing to the output buffer

This commit is contained in:
gdkchan 2018-04-26 11:34:40 -03:00
parent 81e74ebd86
commit 1af78416d1
2 changed files with 5 additions and 5 deletions

View file

@ -45,7 +45,7 @@ namespace Ryujinx.Core.OsHle.Services.Aud
foreach (string Name in DeviceNames) 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) if ((Position - BasePosition) + Buffer.Length > Size)
{ {
@ -71,7 +71,7 @@ namespace Ryujinx.Core.OsHle.Services.Aud
byte[] DeviceNameBuffer = AMemoryHelper.ReadBytes(Context.Memory, Position, Size); 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."); 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 Position = Context.Request.ReceiveBuff[0].Position;
long Size = Context.Request.ReceiveBuff[0].Size; 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) if ((ulong)DeviceNameBuffer.Length <= (ulong)Size)
{ {

View file

@ -32,7 +32,7 @@ namespace Ryujinx.Core.OsHle.Services.Aud
int NameCount = 0; int NameCount = 0;
byte[] DeviceNameBuffer = Encoding.UTF8.GetBytes(DefaultAudioOutput); byte[] DeviceNameBuffer = Encoding.ASCII.GetBytes(DefaultAudioOutput + "\0");
if ((ulong)DeviceNameBuffer.Length <= (ulong)Size) if ((ulong)DeviceNameBuffer.Length <= (ulong)Size)
{ {
@ -67,7 +67,7 @@ namespace Ryujinx.Core.OsHle.Services.Aud
long Position = Context.Request.ReceiveBuff[0].Position; long Position = Context.Request.ReceiveBuff[0].Position;
long Size = Context.Request.ReceiveBuff[0].Size; 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) if ((ulong)DeviceNameBuffer.Length <= (ulong)Size)
{ {