This commit is contained in:
Adam Hathcock
2026-02-13 15:33:13 +00:00
parent 8669948221
commit 0db412d710
4 changed files with 14 additions and 19 deletions

View File

@@ -3,7 +3,7 @@ namespace SharpCompress.Common.SevenZip;
internal class CCoderInfo
{
internal CMethodId _methodId;
internal byte[] _props = [];
internal byte[]? _props;
internal int _numInStreams;
internal int _numOutStreams;
}

View File

@@ -88,13 +88,8 @@ internal class Bcj2DecoderStream : DecoderStream2
private bool _mFinished;
private bool _isDisposed;
public Bcj2DecoderStream(Stream[] streams, byte[] info, long limit)
public Bcj2DecoderStream(Stream[] streams)
{
if (info != null && info.Length > 0)
{
throw new NotSupportedException();
}
if (streams.Length != 4)
{
throw new NotSupportedException();

View File

@@ -18,7 +18,7 @@ internal static partial class DecoderRegistry
internal static async ValueTask<Stream> CreateDecoderStreamAsync(
CMethodId id,
Stream[] inStreams,
byte[] info,
byte[]? info,
IPasswordProvider pass,
long limit,
CancellationToken cancellationToken
@@ -33,18 +33,18 @@ internal static partial class DecoderRegistry
}
return inStreams.Single();
case K_DELTA:
return new DeltaFilter(false, inStreams.Single(), info);
return new DeltaFilter(false, inStreams.Single(), info.NotNull());
case K_LZMA:
case K_LZMA2:
return await LzmaStream
.CreateAsync(info, inStreams.Single(), -1, limit, null, info.Length < 5, false)
.CreateAsync(info.NotNull(), inStreams.Single(), -1, limit, null, info.NotNull().Length < 5, false)
.ConfigureAwait(false);
case CMethodId.K_AES_ID:
return new AesDecoderStream(inStreams.Single(), info, pass, limit);
return new AesDecoderStream(inStreams.Single(), info.NotNull(), pass, limit);
case K_BCJ:
return new BCJFilter(false, inStreams.Single());
case K_BCJ2:
return new Bcj2DecoderStream(inStreams, info, limit);
return new Bcj2DecoderStream(inStreams);
case K_PPC:
return new BCJFilterPPC(false, inStreams.Single());
case K_IA64:
@@ -71,7 +71,7 @@ internal static partial class DecoderRegistry
case K_PPMD:
return await PpmdStream
.CreateAsync(
new PpmdProperties(info),
new PpmdProperties(info.NotNull()),
inStreams.Single(),
false,
cancellationToken

View File

@@ -34,7 +34,7 @@ internal static partial class DecoderRegistry
internal static Stream CreateDecoderStream(
CMethodId id,
Stream[] inStreams,
byte[] info,
byte[]? info,
IPasswordProvider pass,
long limit
)
@@ -48,16 +48,16 @@ internal static partial class DecoderRegistry
}
return inStreams.Single();
case K_DELTA:
return new DeltaFilter(false, inStreams.Single(), info);
return new DeltaFilter(false, inStreams.Single(), info.NotNull());
case K_LZMA:
case K_LZMA2:
return LzmaStream.Create(info, inStreams.Single(), -1, limit);
return LzmaStream.Create(info.NotNull(), inStreams.Single(), -1, limit);
case CMethodId.K_AES_ID:
return new AesDecoderStream(inStreams.Single(), info, pass, limit);
return new AesDecoderStream(inStreams.Single(), info.NotNull(), pass, limit);
case K_BCJ:
return new BCJFilter(false, inStreams.Single());
case K_BCJ2:
return new Bcj2DecoderStream(inStreams, info, limit);
return new Bcj2DecoderStream(inStreams);
case K_PPC:
return new BCJFilterPPC(false, inStreams.Single());
case K_IA64:
@@ -75,7 +75,7 @@ internal static partial class DecoderRegistry
case K_B_ZIP2:
return BZip2Stream.Create(inStreams.Single(), CompressionMode.Decompress, true);
case K_PPMD:
return PpmdStream.Create(new PpmdProperties(info), inStreams.Single(), false);
return PpmdStream.Create(new PpmdProperties(info.NotNull()), inStreams.Single(), false);
case K_DEFLATE:
return new DeflateStream(inStreams.Single(), CompressionMode.Decompress);
case K_ZSTD: