`u -uq3` (anti-item action) on zip and tar silently stores the deleted file as an empty regular file; 7z stores a real anti-item

オープン
#293 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
65/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp
領域
backend

調査の方向性

Start with UpdateCallback.cpp:483-494 and :601-621 to see how anti items reach the format handlers, then compare Archive/7z/7zHandlerOut.cpp:555 with the zip and tar handlers. Reproduce with the supplied commands for zip and tar. Done when the update no longer stores or extracts a deleted item as a zero-byte file, while 7z behavior remains as documented.

索引モデルが issue の本文から書いたものです。

説明

Environment

7-Zip (z) 26.06 (arm64), ip7z/7zip @ d3296e3, macOS 26.4.1 arm64

Steps to reproduce
d=$(mktemp -d) && cd "$d"
for t in 7z zip tar; do
  rm -rf w xo; mkdir w; cd w
  printf aaa > keep.txt; printf bbb > gone.txt
  7zz a -bd -t$t ../x.$t keep.txt gone.txt > /dev/null
  rm gone.txt                                  # file disappears from disk
  7zz u -bd -uq3 ../x.$t keep.txt gone.txt > /dev/null 2>&1   # q3: item only in archive -> anti-item
  cd ..
  echo "== $t"; 7zz l -slt x.$t | grep -E '^(Path|Size|Anti) =' | tail -n +2 | tr '\n' ' '; echo
  7zz x -y -bd -oxo x.$t > /dev/null 2>&1; echo "extracted: $(ls xo | tr '\n' ' ')"
  rm -f x.$t
done

Output:

== 7z    gone.txt Size=0 Anti=+   keep.txt Size=3 Anti=-     extracted: keep.txt
== zip   gone.txt Size=0          keep.txt Size=3            extracted: gone.txt keep.txt
== tar   gone.txt Size=0          keep.txt Size=3            extracted: gone.txt keep.txt

(The u command itself returns 1 because gone.txt is missing on disk; the same happens for 7z.)

Expected

The -u documentation says of action 3 ("Create Anti-item"): "This feature is supported only in 7z format." So for zip and tar the update action should be rejected with an error (or ignored). Either the update action is rejected for formats that cannot represent anti-items, or the archive does not contain gone.txt at all. The archive should not contain a 0-byte file that was never on disk, and extraction should not create it.

Actual

For zip and tar, gone.txt becomes a regular 0-byte entry and is created by extraction. 7z keeps a real anti-item (Anti = +) that is not extracted.

Root cause (analysis on d3296e3)

UpdateCallback.cpp:483-494 and :601-621 report such items to the format handler with size 0 and kpidIsAnti. Only Archive/7z/7zHandlerOut.cpp:555 queries kpidIsAnti. The zip and tar handlers never read it and write the item as a normal empty file.

Suggested fix

In the zip and tar handlers, skip anti items (or fail the update with a clear message) instead of writing an empty file.


Found with a differential test setup (a model of the documented behavior compared against the real binary) and then checked by hand: every command above was re-run verbatim on the tested build, and the root cause was read in the source. Tested commit: d3296e3 (26.06).

主要言語
C++
スター
4.6k
フォーク
519
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ip7z/7zip のほかの issue

ip7z/7zip の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。