tarfile leaks ValueError instead of InvalidHeaderError for a malformed GNU sparse pax number
未关闭
还没有人认领这个 Issue。
stdlib
type-bug
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 36k
- PR 合并指标
- PR 指标待抓取
描述
Bug description:
When a pax extended header carries a malformed GNU sparse number, tarfile parses it with a bare int() and lets the ValueError escape to the caller, unlike the GNU sparse 0.0 handler which reports such corruption as tarfile.InvalidHeaderError.
import tarfile
tarfile.TarInfo("x")._apply_pax_info(
{"GNU.sparse.size": "x"}, "utf-8", "strict") # ValueError
Reporting InvalidHeaderError makes the reader stop at the bad member like the 0.0 format does; a maintainer may prefer to raise instead, so the direction is open.
CPython versions tested on:
3.13, 3.14, 3.15
Operating systems tested on:
macOS
Linked PRs
- gh-153637
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 TarInfo._apply_pax_info 开始,使用 issue 中格式错误的 GNU.sparse.size 示例,并查看链接的 PR gh-153637 以了解当前方向。确认针对格式错误的 GNU sparse pax number 所选择的处理符合预期行为,并且不再泄漏出意外的裸 ValueError。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100