mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-11-17 01:41:02 +00:00
Allow partial reads in ACE signature detection
This commit is contained in:
@@ -100,7 +100,7 @@ public abstract partial class AceHeader
|
||||
// First two bytes are typically 0x60 0xEA (signature bytes)
|
||||
// At offset 7, there should be "**ACE**" (7 bytes)
|
||||
var bytes = new byte[14];
|
||||
if (stream.Read(bytes, 0, 14) != 14)
|
||||
if (!stream.ReadFully(bytes))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
21
tests/SharpCompress.Test/Ace/AceHeaderReadTests.cs
Normal file
21
tests/SharpCompress.Test/Ace/AceHeaderReadTests.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using SharpCompress.Common.Ace.Headers;
|
||||
using SharpCompress.Test.Mocks;
|
||||
using Xunit;
|
||||
|
||||
namespace SharpCompress.Test.Ace;
|
||||
|
||||
public class AceHeaderReadTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task Ace_Signature_Allows_Partial_Reads()
|
||||
{
|
||||
byte[] header = [0, 0, 0, 0, 0, 0, 0, 42, 42, 65, 67, 69, 42, 42];
|
||||
using var sync = new ShortReadStream(new MemoryStream(header));
|
||||
using var asyncInput = new ShortReadStream(new MemoryStream(header));
|
||||
Assert.True(AceHeader.IsArchive(sync));
|
||||
Assert.True(await AceHeader.IsArchiveAsync(asyncInput, CancellationToken.None));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user