Use Stream extension to ensure read operations return the requested number of bytes (unless EOF arrives first).

This commit is contained in:
2022-11-14 09:43:16 +00:00
parent f90cc6593f
commit 0eb589d785
178 changed files with 862 additions and 780 deletions

View File

@@ -48,7 +48,7 @@ public sealed partial class AaruFormat
return false;
_structureBytes = new byte[Marshal.SizeOf<AaruHeader>()];
_imageStream.Read(_structureBytes, 0, _structureBytes.Length);
_imageStream.EnsureRead(_structureBytes, 0, _structureBytes.Length);
_header = Marshal.ByteArrayToStructureLittleEndian<AaruHeader>(_structureBytes);
return _header.identifier is DIC_MAGIC or AARU_MAGIC && _header.imageMajorVersion <= AARUFMT_VERSION;