mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Use Stream extension to ensure read operations return the requested number of bytes (unless EOF arrives first).
This commit is contained in:
@@ -54,7 +54,7 @@ public sealed partial class Nhdr0
|
||||
return false;
|
||||
|
||||
var hdrB = new byte[Marshal.SizeOf<Header>()];
|
||||
stream.Read(hdrB, 0, hdrB.Length);
|
||||
stream.EnsureRead(hdrB, 0, hdrB.Length);
|
||||
|
||||
_nhdhdr = Marshal.ByteArrayToStructureLittleEndian<Header>(hdrB);
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public sealed partial class Nhdr0
|
||||
return ErrorNumber.InvalidArgument;
|
||||
|
||||
var hdrB = new byte[Marshal.SizeOf<Header>()];
|
||||
stream.Read(hdrB, 0, hdrB.Length);
|
||||
stream.EnsureRead(hdrB, 0, hdrB.Length);
|
||||
|
||||
_nhdhdr = Marshal.ByteArrayToStructureLittleEndian<Header>(hdrB);
|
||||
|
||||
@@ -97,7 +97,7 @@ public sealed partial class Nhdr0
|
||||
|
||||
stream.Seek((long)((ulong)_nhdhdr.dwHeadSize + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin);
|
||||
|
||||
stream.Read(buffer, 0, (int)(length * _imageInfo.SectorSize));
|
||||
stream.EnsureRead(buffer, 0, (int)(length * _imageInfo.SectorSize));
|
||||
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user