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:
@@ -35,6 +35,7 @@ namespace Aaru.DiscImages;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.Helpers;
|
||||
using Claunia.RsrcFork;
|
||||
|
||||
public sealed partial class Ndif
|
||||
@@ -57,7 +58,7 @@ public sealed partial class Ndif
|
||||
|
||||
Stream dataFork = imageFilter.GetDataForkStream();
|
||||
var udifMagic = new byte[4];
|
||||
dataFork.Read(udifMagic, 0, 4);
|
||||
dataFork.EnsureRead(udifMagic, 0, 4);
|
||||
|
||||
if(BitConverter.ToUInt32(udifMagic, 0) == 0x796C6F6B)
|
||||
return false;
|
||||
|
||||
@@ -339,7 +339,7 @@ public sealed partial class Ndif
|
||||
{
|
||||
var cmpBuffer = new byte[currentChunk.length];
|
||||
_imageStream.Seek(currentChunk.offset, SeekOrigin.Begin);
|
||||
_imageStream.Read(cmpBuffer, 0, cmpBuffer.Length);
|
||||
_imageStream.EnsureRead(cmpBuffer, 0, cmpBuffer.Length);
|
||||
int realSize;
|
||||
|
||||
switch(currentChunk.type)
|
||||
@@ -402,7 +402,7 @@ public sealed partial class Ndif
|
||||
case CHUNK_TYPE_COPY:
|
||||
_imageStream.Seek(currentChunk.offset + relOff, SeekOrigin.Begin);
|
||||
buffer = new byte[SECTOR_SIZE];
|
||||
_imageStream.Read(buffer, 0, buffer.Length);
|
||||
_imageStream.EnsureRead(buffer, 0, buffer.Length);
|
||||
|
||||
if(_sectorCache.Count >= MAX_CACHED_SECTORS)
|
||||
_sectorCache.Clear();
|
||||
|
||||
Reference in New Issue
Block a user