mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-12-22 23:55:47 +00:00
Avoid inexact read with 'Stream.Read' (#6847)
This commit is contained in:
parent
971d24aef0
commit
888402ecaf
7 changed files with 8 additions and 8 deletions
|
@ -237,7 +237,7 @@ namespace ARMeilleure.CodeGen.Arm64
|
||||||
long originalPosition = _stream.Position;
|
long originalPosition = _stream.Position;
|
||||||
|
|
||||||
_stream.Seek(0, SeekOrigin.Begin);
|
_stream.Seek(0, SeekOrigin.Begin);
|
||||||
_stream.Read(code, 0, code.Length);
|
_stream.ReadExactly(code, 0, code.Length);
|
||||||
_stream.Seek(originalPosition, SeekOrigin.Begin);
|
_stream.Seek(originalPosition, SeekOrigin.Begin);
|
||||||
|
|
||||||
RelocInfo relocInfo;
|
RelocInfo relocInfo;
|
||||||
|
|
|
@ -1444,7 +1444,7 @@ namespace ARMeilleure.CodeGen.X86
|
||||||
|
|
||||||
Span<byte> buffer = new byte[jump.JumpPosition - _stream.Position];
|
Span<byte> buffer = new byte[jump.JumpPosition - _stream.Position];
|
||||||
|
|
||||||
_stream.Read(buffer);
|
_stream.ReadExactly(buffer);
|
||||||
_stream.Seek(ReservedBytesForJump, SeekOrigin.Current);
|
_stream.Seek(ReservedBytesForJump, SeekOrigin.Current);
|
||||||
|
|
||||||
codeStream.Write(buffer);
|
codeStream.Write(buffer);
|
||||||
|
|
|
@ -195,7 +195,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
||||||
switch (algorithm)
|
switch (algorithm)
|
||||||
{
|
{
|
||||||
case CompressionAlgorithm.None:
|
case CompressionAlgorithm.None:
|
||||||
stream.Read(data);
|
stream.ReadExactly(data);
|
||||||
break;
|
break;
|
||||||
case CompressionAlgorithm.Deflate:
|
case CompressionAlgorithm.Deflate:
|
||||||
stream = new DeflateStream(stream, CompressionMode.Decompress, true);
|
stream = new DeflateStream(stream, CompressionMode.Decompress, true);
|
||||||
|
|
|
@ -220,7 +220,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
||||||
}
|
}
|
||||||
|
|
||||||
dataFileStream.Seek((long)entry.Offset, SeekOrigin.Begin);
|
dataFileStream.Seek((long)entry.Offset, SeekOrigin.Begin);
|
||||||
dataFileStream.Read(cb1Data);
|
dataFileStream.ReadExactly(cb1Data);
|
||||||
BinarySerializer.ReadCompressed(dataFileStream, guestCode);
|
BinarySerializer.ReadCompressed(dataFileStream, guestCode);
|
||||||
|
|
||||||
_cache[index] = (guestCode, cb1Data);
|
_cache[index] = (guestCode, cb1Data);
|
||||||
|
@ -279,7 +279,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
||||||
dataFileStream.Seek((long)entry.Offset, SeekOrigin.Begin);
|
dataFileStream.Seek((long)entry.Offset, SeekOrigin.Begin);
|
||||||
byte[] cachedCode = new byte[entry.CodeSize];
|
byte[] cachedCode = new byte[entry.CodeSize];
|
||||||
byte[] cachedCb1Data = new byte[entry.Cb1DataSize];
|
byte[] cachedCb1Data = new byte[entry.Cb1DataSize];
|
||||||
dataFileStream.Read(cachedCb1Data);
|
dataFileStream.ReadExactly(cachedCb1Data);
|
||||||
BinarySerializer.ReadCompressed(dataFileStream, cachedCode);
|
BinarySerializer.ReadCompressed(dataFileStream, cachedCode);
|
||||||
|
|
||||||
if (data.SequenceEqual(cachedCode) && cb1Data.SequenceEqual(cachedCb1Data))
|
if (data.SequenceEqual(cachedCode) && cb1Data.SequenceEqual(cachedCb1Data))
|
||||||
|
|
|
@ -233,7 +233,7 @@ namespace Ryujinx.UI.Windows
|
||||||
reader.ReadInt64(); // Padding
|
reader.ReadInt64(); // Padding
|
||||||
|
|
||||||
byte[] input = new byte[stream.Length - stream.Position];
|
byte[] input = new byte[stream.Length - stream.Position];
|
||||||
stream.Read(input, 0, input.Length);
|
stream.ReadExactly(input, 0, input.Length);
|
||||||
|
|
||||||
long inputOffset = 0;
|
long inputOffset = 0;
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace Ryujinx.UI.App.Common
|
||||||
Stream resourceStream = Assembly.GetCallingAssembly().GetManifestResourceStream(resourceName);
|
Stream resourceStream = Assembly.GetCallingAssembly().GetManifestResourceStream(resourceName);
|
||||||
byte[] resourceByteArray = new byte[resourceStream.Length];
|
byte[] resourceByteArray = new byte[resourceStream.Length];
|
||||||
|
|
||||||
resourceStream.Read(resourceByteArray);
|
resourceStream.ReadExactly(resourceByteArray);
|
||||||
|
|
||||||
return resourceByteArray;
|
return resourceByteArray;
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
reader.ReadInt64(); // Padding
|
reader.ReadInt64(); // Padding
|
||||||
|
|
||||||
byte[] input = new byte[stream.Length - stream.Position];
|
byte[] input = new byte[stream.Length - stream.Position];
|
||||||
stream.Read(input, 0, input.Length);
|
stream.ReadExactly(input, 0, input.Length);
|
||||||
|
|
||||||
uint inputOffset = 0;
|
uint inputOffset = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue