1084 Commits

Author SHA1 Message Date
Adam Hathcock
cad378b61c Fix streaming ZIP reads after deflated directory entries 2026-11-14 09:50:04 +00:00
Adam Hathcock
e676a26f05 Remove openentrystream checks 2026-11-13 11:39:14 +00:00
Adam Hathcock
4b82e1728e Avoid quadratic header parsing when switching archive enumeration APIs 2026-11-13 10:55:55 +00:00
Adam Hathcock
331808d004 Use shared archive entry views for completeness checks 2026-11-13 10:55:26 +00:00
Adam Hathcock
2b9295ce36 Fix GZip header position when resuming partial enumeration 2026-11-13 10:54:49 +00:00
Adam Hathcock
d4db8abac8 Parse decoded 7z metadata directly from pooled storage 2026-11-13 09:59:57 +00:00
Adam Hathcock
da868e2f47 Share writable archive entry identities across sync and async APIs 2026-11-13 09:44:27 +00:00
Adam Hathcock
e19010b184 Validate LZMA2 dictionary limits before parallel workers 2026-11-13 09:38:46 +00:00
Adam Hathcock
2f040283fc Preserve legacy 7z property size compatibility during preflight 2026-11-13 09:36:55 +00:00
Adam Hathcock
101c939cc6 Exclude trusted LZMA2 writer trials from LZMA input limits 2026-11-13 09:35:09 +00:00
Adam Hathcock
7f7b8c7eda Validate effective TAR PAX sizes before streaming 2026-11-13 09:33:35 +00:00
Adam Hathcock
b10627339c Normalize TAR duplicate keys consistently with the writer 2026-11-13 09:32:21 +00:00
Adam Hathcock
85bf5141e6 Reject unsupported Zstandard window limits at assignment 2026-11-13 09:31:43 +00:00
Adam Hathcock
f2e4df509b Keep LZMA decoders retryable after dictionary limit rejection 2026-11-13 09:28:53 +00:00
Adam Hathcock
09b95f1841 Fix PPMd properties state after rejected allocator changes 2026-11-13 09:27:51 +00:00
Adam Hathcock
b76c336658 Merge remote-tracking branch 'origin/release' into adam/merge-release-into-master
# Conflicts:
#	.github/workflows/nuget-release.yml
#	src/SharpCompress/Common/SevenZip/ArchiveReader.Async.cs
#	src/SharpCompress/Common/SevenZip/ArchiveReader.cs
2026-11-12 16:52:39 +00:00
Adam Hathcock
760eef37ab Merge commit from fork
Fix GHSA-xmfm-xg76-qx62: bound decompression dictionary allocations
2026-11-12 15:09:10 +00:00
Adam Hathcock
e9a6045c88 Merge commit from fork
Prevent excessive allocations from forged 7z header fields
2026-11-12 15:07:57 +00:00
Adam Hathcock
1ba0eaa629 Merge commit from fork
Reject negative TAR entry sizes and overflowing seek offsets
2026-11-12 15:07:09 +00:00
Adam Hathcock
cecd8543a4 Bound decompression dictionaries with static size limits 2026-11-09 13:23:53 +00:00
Adam Hathcock
8ec2188ee0 Validate 7z header counts before allocation
Bound nested metadata counts and coder properties by their backing data, validate file and stream consistency, and buffer decoded headers incrementally instead of reserving attacker-declared output sizes.

Add synchronous and asynchronous allocation regressions for GHSA-vwpg-q8vc-g6fg, including external metadata and valid bit-packed empty entries.
2026-11-09 11:53:34 +00:00
Adam Hathcock
30586fdcc5 Validate full-width TAR binary sizes
Combine the decoder and padding size bounds from advisory PR #1 with the checked seek offsets and sync/async regression coverage in PR #2.

Co-authored-by: 4nonym0us <2701409+4nonym0us@users.noreply.github.com>
2026-11-09 11:34:11 +00:00
Adam Hathcock
46ba719daa Reject negative TAR entry sizes and overflowing seek offsets 2026-11-09 11:28:55 +00:00
Adam Hathcock
fa3dff056a Reject stalled BZip2 decoder states after corruption 2026-11-09 11:16:14 +00:00
Adam Hathcock
990186acc5 Fix writable archive duplicate entry checks 2026-11-06 16:03:00 +00:00
Adam Hathcock
82cc8c98c4 Update .NET SDK to address AOT restore vulnerability 2026-11-06 09:24:18 +00:00
Adam Hathcock
9a04b51c0b Reject Deflate back-references beyond initialized history 2026-11-04 17:03:41 +00:00
Adam Hathcock
d5014d3a1c fix legacy test 2026-11-02 16:11:45 +00:00
Adam Hathcock
688f1f7036 Fix solid 7z Deflate entry extraction 2026-11-02 13:27:58 +00:00
Adam Hathcock
6128ec51ee Merge pull request #1484 from adamhathcock/chore/update-nuget-and-sdk
Update NuGet packages and .NET SDK
2026-10-31 10:35:09 +00:00
Adam Hathcock
872274d2f8 Update NuGet packages and .NET SDK 2026-10-31 10:10:40 +00:00
drone1400
fb0cd47bb0 Add tests for long USTAR names split at a directory separator
When an entry name is longer than the 100 byte USTAR name field,
TarHeader splits it into the 155 byte prefix field and the name field
at a directory separator. The existing tests only covered short paths
and long names without any separator.

Add sync and async tests that write a 186 byte path (with '/' and
'\' separators as input) using the USTAR format and read it back.

On Windows these tests fail with InvalidFormatException ("Directory
separator not found!"), which the next commit fixes. They pass on
Linux and macOS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 11:48:10 +02:00
Adam Hathcock
c4028139fd Report invalid LZMA2 chunk properties as a data error
An LZMA2 chunk header properties byte of 225 or more cannot occur in
valid data, but it reached Decoder.SetDecoderProperties and surfaced as
InvalidParamException. EncryptedDecoderStream only maps DataErrorException
to CryptographicException, so a wrong 7z password occasionally leaked the
internal codec exception, making
SevenZipWriter_Encrypted_WrongPasswordFails flaky.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 15:02:07 +00:00
Adam Hathcock
51c00c62d8 Merge pull request #1480 from wleeaf/empty-compressed-streams
Write a valid compressed stream when no data is written
2026-10-27 13:48:40 +00:00
Adam Hathcock
c6712678d6 Merge pull request #1479 from wleeaf/zip-utf8-name-flag
Set the UTF-8 flag for zip entry names encoded as UTF-8 without a BOM
2026-10-27 13:47:53 +00:00
Wleeaf
aa54f11acc Write a valid compressed stream when no data is written 2026-10-26 20:47:22 +00:00
Wleeaf
ea2986708f Set the UTF-8 flag for zip entry names encoded as UTF-8 without a BOM 2026-10-26 16:48:33 +00:00
Adam Hathcock
deaabb5504 Merge pull request #1469 from adamhathcock/dependabot/nuget/build/all-dependencies-232486072c
Bump the all-dependencies group with 5 updates
2026-10-26 16:35:15 +00:00
Adam Hathcock
dd6d09c6d2 Reduce allocations in 7z encryption and codec lookup 2026-10-26 13:45:21 +00:00
Adam Hathcock
fa96277b96 Merge pull request #1476 from jaysanati/feature/7z-write-encryption-master
SevenZipWriter: password protection (7zAES) and encrypted headers
2026-10-26 13:17:32 +00:00
Adam Hathcock
2fa1dec513 Merge pull request #1473 from adamhathcock/review/fix-zip64-descriptor-width
Fix ZIP64 streaming data descriptor width parsing
2026-10-26 11:36:16 +00:00
Adam Hathcock
8fa17607d8 Merge pull request #1477 from adamhathcock/perf/xz-async-decoding
Optimize XZ async reads and buffered LZMA2 decoding
2026-10-26 08:27:00 +00:00
Adam Hathcock
0a716d4236 Merge pull request #1475 from jaysanati/fix/7z-encrypted-compression-type
Report the codec, not 7zAES, as an encrypted 7z entry's CompressionType
2026-10-26 08:24:34 +00:00
Jay Sanati
521a33688a Add 7z write encryption (7zAES) and encrypted headers
SevenZipWriterOptions gains Password and EncryptHeader (#1472). With a
password, each folder is written as 7zAES -> LZMA/LZMA2 in the same
layout 7-Zip uses: AES is coder 0 and reads the packed stream, the
codec is coder 1 and reads AES's output. AES properties match 7-Zip's
defaults (NumCyclesPower 19, no salt, random 16-byte IV per folder), so
the key is derived once per archive. EncryptHeader runs the header
through the same chain; an encrypted header is always LZMA-compressed.
Empty files have no stream and stay unencrypted, as in 7-Zip.

- SevenZipAesKey: the 7zAES KDF, moved unchanged from AesDecoderStream
  so the encoder and decoder share it.
- AesEncoderStream: AES-256-CBC, zero-fills the last block on Finish.
- SevenZipAesEncryption: per-archive key and per-folder IV/properties.
- EncryptHeader without a password, or an empty password, throws
  ArgumentException.

Uses only Aes (CBC) and SHA256, available on every target framework and
Native AOT safe. Verified with 7-Zip 26.05 (7z t, 7z x, 7z l -slt) and
WinRAR for LZMA and LZMA2, with and without header encryption.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 13:27:20 -07:00
Jay Sanati
a7d3b100a0 Report the codec, not 7zAES, as an encrypted 7z entry's CompressionType
7-Zip writes 7zAES as the first coder of an encrypted folder, in front
of the codec. SevenZipFilePart.GetCompression() looked at the first
coder only, so CompressionType threw InvalidFormatException for every
entry of a 7-Zip-made encrypted archive. Skip the AES filter and report
the first real coder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 13:27:20 -07:00
Jay Sanati
6d51b39230 Report the codec, not 7zAES, as an encrypted 7z entry's CompressionType
7-Zip writes 7zAES as the first coder of an encrypted folder, in front
of the codec. SevenZipFilePart.GetCompression() looked at the first
coder only, so CompressionType threw InvalidFormatException for every
entry of a 7-Zip-made encrypted archive. Skip the AES filter and report
the first real coder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 12:03:46 -07:00
Adam Hathcock
ba248dc01e Decode asynchronously buffered LZMA2 chunks with the fast CPU path 2026-10-24 13:37:15 +01:00
Adam Hathcock
31f3476fc9 Add native ValueTask memory reads through XZ filter chains 2026-10-24 13:09:51 +01:00
Adam Hathcock
de7a5d9ad4 Avoid duplicate task results in XZ BCJ array reads 2026-10-24 12:54:39 +01:00
Adam Hathcock
f7451966ec Document XZ BCJ pooling evaluation and add benchmarks 2026-10-24 12:42:57 +01:00