Read ARC entry headers fully on fragmented streams

This commit is contained in:
Adam Hathcock
2026-10-10 15:40:35 +01:00
parent b442327e5f
commit 2a68ec7257
2 changed files with 28 additions and 6 deletions

View File

@@ -26,7 +26,7 @@ public class ArcEntryHeader
public ArcEntryHeader? ReadHeader(Stream stream)
{
byte[] headerBytes = new byte[29];
if (stream.Read(headerBytes, 0, headerBytes.Length) != headerBytes.Length)
if (!stream.ReadFully(headerBytes))
{
return null;
}
@@ -40,11 +40,7 @@ public class ArcEntryHeader
)
{
byte[] headerBytes = new byte[29];
if (
await stream
.ReadAsync(headerBytes, 0, headerBytes.Length, cancellationToken)
.ConfigureAwait(false) != headerBytes.Length
)
if (!await stream.ReadFullyAsync(headerBytes, cancellationToken).ConfigureAwait(false))
{
return null;
}