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

@@ -132,7 +132,7 @@ public sealed class PcExchange : IFilter
{
var datEntry = new Entry();
var datEntryB = new byte[Marshal.SizeOf(datEntry)];
finderDatStream.Read(datEntryB, 0, Marshal.SizeOf(datEntry));
finderDatStream.EnsureRead(datEntryB, 0, Marshal.SizeOf(datEntry));
datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian<Entry>(datEntryB);
// TODO: Add support for encoding on filters
@@ -190,7 +190,7 @@ public sealed class PcExchange : IFilter
{
var datEntry = new Entry();
var datEntryB = new byte[Marshal.SizeOf(datEntry)];
finderDatStream.Read(datEntryB, 0, Marshal.SizeOf(datEntry));
finderDatStream.EnsureRead(datEntryB, 0, Marshal.SizeOf(datEntry));
datEntry = Helpers.Marshal.ByteArrayToStructureBigEndian<Entry>(datEntryB);
string macName = StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh"));