From 5be5b51c9233cc6e82fc4ad9b12d29efc39e3303 Mon Sep 17 00:00:00 2001 From: pappadf <95528397+pappadf@users.noreply.github.com> Date: Thu, 9 Apr 2026 21:36:40 +0000 Subject: [PATCH] Fix SIT classic parser miscounting folder markers as files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Folder start (0x20) and folder end (0x21) markers were incorrectly incrementing the `done` counter in parse_classic(), causing the iteration loop to terminate early when archives contained folders. The SIT spec (sit.md § 4.7) explicitly states: "Folder markers do not contribute to file_count." The file_count field only counts actual file entries, not structural folder markers. This caused archives like SSW_7.0-800k.sit.Hqx (which wraps a single file inside a folder) to extract zero files: the folder-start marker consumed the entire file_count budget of 1, and the loop exited before reaching the actual file entry. Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/formats/sit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/formats/sit.c b/lib/formats/sit.c index b86d908..3e58a93 100644 --- a/lib/formats/sit.c +++ b/lib/formats/sit.c @@ -602,6 +602,7 @@ static bool parse_classic(const uint8_t *blob, size_t blob_len, uint8_t dm = hdr[1]; // sit.md § 4.4 — folder start marker (0x20) + // Folder markers do NOT count toward file_count (sit.md § 4.7). if (rm == SIT_FOLDER_START || dm == SIT_FOLDER_START) { uint8_t nlen = hdr[2]; if (depth < SIT_MAX_DEPTH && nlen < 64) { @@ -610,15 +611,14 @@ static bool parse_classic(const uint8_t *blob, size_t blob_len, depth++; } cursor += SIT_ENTRY_HDR_SIZE; - done++; continue; } // sit.md § 4.4 — folder end marker (0x21) + // Folder markers do NOT count toward file_count (sit.md § 4.7). if (rm == SIT_FOLDER_END || dm == SIT_FOLDER_END) { if (depth > 0) depth--; cursor += SIT_ENTRY_HDR_SIZE; - done++; continue; }