tar: a pax extended header is ignored as a whole if any record value contains a NUL byte (e.g. `SCHILY.xattr.*`); long `path` is lost
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start with CPP/7zip/Archive/Tar/TarIn.cpp, especially CPaxInfo::ParsePax() around lines 683–685 and the caller around lines 1017–1020. Reproduce with repro/lar001.sh and compare the listed filename with the expected 101-character path. Done when a NUL in an uninterpreted xattr record no longer prevents the valid path record from being applied.
索引モデルが issue の本文から書いたものです。
説明
Environment
- 7-Zip (z) 26.06 (arm64),
ip7z/7zip@d3296e3, built withCPP/7zip/cmpl_mac_arm64.mak(Bundles/Alone2) - macOS 26.4.1 arm64, Apple clang 21.0.0; /usr/bin/tar = bsdtar 3.5.3 (libarchive 3.7.4)
Description
bsdtar and GNU tar write extended attributes into a pax header as SCHILY.xattr.<name>=<raw bytes>. The value is binary and can contain NUL. When one record of an extended header has a NUL in its value, 7-Zip marks the whole header as erroneous and uses none of its records. A 101-character path is therefore replaced by the 98 characters of the ustar name field. mtime, size and linkpath records of the same header are dropped in the same way (the mtime loss was observed in round 1, not re-tested here).
Steps to reproduce
d=/tmp/verify4_LAR001/r; rm -rf "$d"; mkdir -p "$d/s" && cd "$d"
N=$(python3 -c "print('n'*100+'x')") # 101 characters
printf hello > "s/$N" # on macOS, files under /tmp get a binary com.apple.provenance xattr
(cd s && /usr/bin/tar --format pax -cf ../real.tar "$N")
/usr/bin/tar -tf real.tar | awk '{print length($0)}' # 101 (and 103 for the ._ AppleDouble entry)
7zz l -slt real.tar | awk '/^Path = /{print length($0)-7}' # 98 for the item, plus a "Headers Error" warning
7zz x -y -bd -oxx real.tar; echo rc=$?; ls xx | awk '{print length($0)}' # rc=0, a 98-character file name
Minimal synthetic version: repro/lar001.sh in the bundle builds a pax header with path plus SCHILY.xattr.user.a=a\0b. Results (identical in two runs):
path only expected len=101 7zz len=[101]
path + xattr value without NUL expected len=101 7zz len=[101]
path + xattr value with NUL expected len=101 7zz len=[98]
Expected
path from the extended header overrides the ustar name/prefix fields. POSIX pax: the path keyword "shall define the pathname of the following file" and "overrides the name and prefix fields" (quoted from memory of POSIX.1-2017 pax, not re-fetched). Unknown keywords such as SCHILY.xattr.* must be ignored by readers, not invalidate other records. bsdtar -tf and python tarfile list the 101-character name for the same file.
Actual
7zz lists and extracts the 98-character prefix of the name. rc=0, with only a WARNINGS: Headers Error line.
Root cause (analysis on d3296e3)
CPP/7zip/Archive/Tar/TarIn.cpp:683-685inCPaxInfo::ParsePax():for (i = offset; i < size; i++) if (s[i] == 0) return false;rejects a record containing NUL anywhere, including in the value of a record that is not interpreted.TarIn.cpp:1017-1018: whenParsePax()returns false onlyitem.Pax_Error = trueis set. Theelsebranch that appliesPath,Link,Sizeand times (lines 1020 onward) is skipped for every record.TarIn.cpp:1139-1141:Pax_Errorbecomes an archive-level warning, which is what the user sees.
Suggested fix
Reject NUL only in the keyword, or only in records whose keyword 7-Zip interprets (path, linkpath, uname, gname, ...). For other records skip them with the length field as the delimiter. Alternatively, parse record by record and keep the records that parsed correctly.
Found with a differential test setup (a model of the documented behavior, and for some reports an independent tool such as libarchive/bsdtar, 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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ip7z/7zip のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
area::installer documentation engine::sd enhancement wg::platform-core
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
lemonade-sdk/lemonade#4349 ·
メンテナーはふだん 1 日以内に返信
-
Python example: list a model's scenes and their cameras対応中かも @rudraparmar76 が今日担当しました。 オープンdocumentation good first issue python
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
iamahsanmehmood/openskp#796 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
tenstorrent/tt-umd#4183 ·
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
odelaneau/GLIMPSE#353 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信