diff --git a/.github/hooks/rtk-rewrite.json b/.github/hooks/rtk-rewrite.json deleted file mode 100644 index eb2a5a7f..00000000 --- a/.github/hooks/rtk-rewrite.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "hooks": { - "PreToolUse": [ - { - "type": "command", - "command": "rtk hook copilot", - "cwd": ".", - "timeout": 5 - } - ] - } -} diff --git a/global.json b/global.json index a6dc747f..f5d6141c 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "10.0.300", + "version": "10.0.301", "rollForward": "disable" } } diff --git a/src/SharpCompress/Factories/GZipFactory.cs b/src/SharpCompress/Factories/GZipFactory.cs index 92a8bbef..bda6ef1f 100644 --- a/src/SharpCompress/Factories/GZipFactory.cs +++ b/src/SharpCompress/Factories/GZipFactory.cs @@ -142,10 +142,14 @@ public class GZipFactory if (GZipArchive.IsGZipFile(sharpCompressStream)) { sharpCompressStream.Rewind(); - using var testStream = options.Providers.CreateDecompressStream( - CompressionType.GZip, - SharpCompressStream.CreateNonDisposing(sharpCompressStream), - CompressionContext.FromStream(sharpCompressStream).WithReaderOptions(options) + // Do not dispose the probe GZip stream directly. Disposing after a partial probe read + // can throw in the decompressor finalize path, so probe through a non-disposing wrapper. + using var testStream = SharpCompressStream.CreateNonDisposing( + options.Providers.CreateDecompressStream( + CompressionType.GZip, + SharpCompressStream.CreateNonDisposing(sharpCompressStream), + CompressionContext.FromStream(sharpCompressStream).WithReaderOptions(options) + ) ); if (TarArchive.IsTarFile(testStream)) { diff --git a/src/SharpCompress/packages.lock.json b/src/SharpCompress/packages.lock.json index 13d0ce05..54571844 100644 --- a/src/SharpCompress/packages.lock.json +++ b/src/SharpCompress/packages.lock.json @@ -321,9 +321,9 @@ "net10.0": { "Microsoft.NET.ILLink.Tasks": { "type": "Direct", - "requested": "[10.0.8, )", - "resolved": "10.0.8", - "contentHash": "dVbSXGIFNR5nZcv2tOLoWI+a9T4jtFd77IYjuND+QVe360qWgAF7H0WtoopYhRw/+SgpGUTyrkrh+65+ClNnfw==" + "requested": "[10.0.9, )", + "resolved": "10.0.9", + "contentHash": "4Iw41e2h7I4t70SJcX2GCmbyKJIlA273Cfm9RJMM050/3VBejGAG1KcthP5Z2L6SQcbfbf6BhNWO26+ZG+GzMg==" }, "Microsoft.NETFramework.ReferenceAssemblies": { "type": "Direct", @@ -441,9 +441,9 @@ "net8.0": { "Microsoft.NET.ILLink.Tasks": { "type": "Direct", - "requested": "[8.0.27, )", - "resolved": "8.0.27", - "contentHash": "rQi9TxifHRnXP7lVRZH05DxD2/XGbJp12q0ozcbrlBlBnyyzssFTH/2vLhtKWUp2CT1qVscTrcYTFiwTyKPKRg==" + "requested": "[8.0.28, )", + "resolved": "8.0.28", + "contentHash": "XMqgVjlLxLqWmEh3c49haXLQwsMNtvo6YscUaqfvEGfg1iA8hnYgkUVq3i9Zu9gKeNKMWiiZKVwZExc/qyEAsQ==" }, "Microsoft.NETFramework.ReferenceAssemblies": { "type": "Direct", diff --git a/tests/SharpCompress.AotSmoke/packages.lock.json b/tests/SharpCompress.AotSmoke/packages.lock.json index bfbb6d92..19031145 100644 --- a/tests/SharpCompress.AotSmoke/packages.lock.json +++ b/tests/SharpCompress.AotSmoke/packages.lock.json @@ -4,15 +4,15 @@ "net10.0": { "Microsoft.DotNet.ILCompiler": { "type": "Direct", - "requested": "[10.0.8, )", - "resolved": "10.0.8", - "contentHash": "RJxitcN5CCyZDcPNXKLsecwKvACzmy8C1z8hGM9+hFcnPhv1jDysJFFIeUHIPWaZ6wDAfYtZcgKEtegvL2Nz8A==" + "requested": "[10.0.9, )", + "resolved": "10.0.9", + "contentHash": "4y+VsQOcs4EiTSINdCpCWi/aLRbIbGTxSezQXd8uGVhzbDRm1FNVTZDyCUQixE0+g9UFusvfxVcF68YYz7RzxA==" }, "Microsoft.NET.ILLink.Tasks": { "type": "Direct", - "requested": "[10.0.8, )", - "resolved": "10.0.8", - "contentHash": "dVbSXGIFNR5nZcv2tOLoWI+a9T4jtFd77IYjuND+QVe360qWgAF7H0WtoopYhRw/+SgpGUTyrkrh+65+ClNnfw==" + "requested": "[10.0.9, )", + "resolved": "10.0.9", + "contentHash": "4Iw41e2h7I4t70SJcX2GCmbyKJIlA273Cfm9RJMM050/3VBejGAG1KcthP5Z2L6SQcbfbf6BhNWO26+ZG+GzMg==" }, "Microsoft.NETFramework.ReferenceAssemblies": { "type": "Direct", @@ -76,17 +76,17 @@ "net10.0/linux-x64": { "Microsoft.DotNet.ILCompiler": { "type": "Direct", - "requested": "[10.0.8, )", - "resolved": "10.0.8", - "contentHash": "RJxitcN5CCyZDcPNXKLsecwKvACzmy8C1z8hGM9+hFcnPhv1jDysJFFIeUHIPWaZ6wDAfYtZcgKEtegvL2Nz8A==", + "requested": "[10.0.9, )", + "resolved": "10.0.9", + "contentHash": "4y+VsQOcs4EiTSINdCpCWi/aLRbIbGTxSezQXd8uGVhzbDRm1FNVTZDyCUQixE0+g9UFusvfxVcF68YYz7RzxA==", "dependencies": { - "runtime.linux-x64.Microsoft.DotNet.ILCompiler": "10.0.8" + "runtime.linux-x64.Microsoft.DotNet.ILCompiler": "10.0.9" } }, "runtime.linux-x64.Microsoft.DotNet.ILCompiler": { "type": "Transitive", - "resolved": "10.0.8", - "contentHash": "0jxyi69frgaqADCnEpHE+f65NoiRTAjfjvNDMOxWV77BumQ56eMDL4ECw29DcJTqwaYJQ92PqDS6y6CiLf7kgw==" + "resolved": "10.0.9", + "contentHash": "45CVefG8S0eUKUJ4LBWOi8FOAgMJOP6exW9l5M9OjvQaGR7jvkokBK50XaZCsO66uLxABcuzvncV8A3YiJLUgw==" } } } diff --git a/tests/SharpCompress.Test/GZip/GZipReaderTests.cs b/tests/SharpCompress.Test/GZip/GZipReaderTests.cs index 665b6f8f..fb3936a8 100644 --- a/tests/SharpCompress.Test/GZip/GZipReaderTests.cs +++ b/tests/SharpCompress.Test/GZip/GZipReaderTests.cs @@ -1,6 +1,8 @@ using System.IO; +using System.IO.Compression; using SharpCompress.Common; using SharpCompress.IO; +using SharpCompress.Readers; using SharpCompress.Readers.GZip; using Xunit; @@ -25,4 +27,27 @@ public class GZipReaderTests : ReaderTests Assert.NotEqual(0, reader.Entry.Crc); } } + + [Fact] + public void GZip_ReaderFactory_FlatGZip() + { + var source = new byte[2048]; + for (var i = 0; i < source.Length; i++) + { + source[i] = 0xFF; + } + + var gzipPath = Path.Combine(SCRATCH_FILES_PATH, "Flat.bin.gz"); + using (var output = File.Create(gzipPath)) + using (var gzip = new GZipStream(output, CompressionMode.Compress)) + { + gzip.Write(source, 0, source.Length); + } + + using var stream = File.OpenRead(gzipPath); + using var reader = ReaderFactory.OpenReader(stream); + Assert.IsType(reader); + Assert.True(reader.MoveToNextEntry()); + Assert.False(reader.MoveToNextEntry()); + } }