Skip to content

fix: exclude oversize El Torito [BOOT] entry during iso extraction - #136

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
LiHua000:master
Sep 16, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
LiHua000:master

Conversation

@LiHua000

@LiHua000 LiHua000 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor
  • Scan 7z l -slt before extraction and exclude only [BOOT] entries larger than 4GiB-1 (the FAT32 single file limit)
  • Parse only Path/Folder/Size so it works with both old p7zip and new 7-Zip
  • Fall back to no exclusion when the scan fails; small [BOOT] entries are kept

Log: Fix making bootable USB from large ISO images whose El Torito [BOOT] entry exceeds the FAT32 file size limit

Bug: https://pms.uniontech.com/bug-view-377229.html

Summary by Sourcery

Exclude oversized El Torito boot entries during ISO extraction to support creating bootable FAT32 USB media from large images.

Bug Fixes:

  • Prevent ISO extraction failures on FAT32 targets by excluding only El Torito [BOOT] files larger than the FAT32 single-file limit.
  • Preserve small [BOOT] entries and fall back to the existing extraction behavior when archive scanning fails or unsupported 7-Zip output is encountered.

Enhancements:

  • Add compatibility-focused parsing of 7z listing output across old p7zip and new 7-Zip versions.

Tests:

  • Add coverage for oversized boot entries, legacy p7zip listings, and small boot entries.

- Scan `7z l -slt` before extraction and exclude only [BOOT] entries larger than 4GiB-1 (the FAT32 single file limit)
- Parse only Path/Folder/Size so it works with both old p7zip and new 7-Zip
- Fall back to no exclusion when the scan fails; small [BOOT] entries are kept

Log: Fix making bootable USB from large ISO images whose El Torito [BOOT] entry exceeds the FAT32 file size limit

Bug: https://pms.uniontech.com/bug-view-377229.html
@sourcery-ai

sourcery-ai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Reviewer's Guide

Before extracting an ISO, the implementation scans machine-readable 7-Zip listing output, filters oversized synthetic El Torito [BOOT] files that cannot fit on FAT32, and passes precise exclusions to extraction while preserving compatibility through a no-exclusion fallback. Unit tests cover new and old listing formats plus small boot images.

Sequence diagram for excluding oversized El Torito entries during ISO extraction

sequenceDiagram
    participant SevenZip
    participant ListProcess as 7z listing process
    participant ExtractProcess as 7z extraction process

    SevenZip->>ListProcess: start(l, -slt, archiveFile)
    ListProcess-->>SevenZip: Path, Folder, Size output
    SevenZip->>SevenZip: parseOversizeBootPaths(sltOutput)
    alt oversized [BOOT] file detected
        SevenZip->>ExtractProcess: extract archive with -x![BOOT]/path
    else scan fails or no oversized entry
        SevenZip->>ExtractProcess: extract archive without exclusion
    end
    ExtractProcess-->>SevenZip: extraction result
Loading

Flow diagram for identifying FAT32-incompatible boot entries

flowchart TD
    A[7z l -slt archive] --> B[Parse Path, Folder, Size]
    B --> C{"File under [BOOT]/?"}
    C -- No --> D[Keep entry]
    C -- Yes --> E{Size greater than 4GiB - 1?}
    E -- No --> D
    E -- Yes --> F[Add exact path to exclusion list]
    F --> G[Extract ISO with -x! exclusions]
    D --> G
    A -. scan failure .-> H[Extract without exclusions]
Loading

File-Level Changes

Change Details Files
Adds a pre-extraction scan that identifies only oversized El Torito [BOOT] files and excludes them from extraction when they exceed the FAT32 single-file limit.
  • Runs 7z l -slt in a dedicated process before extraction.
  • Parses only Path, Folder, and Size fields for compatibility with old p7zip and new 7-Zip output.
  • Excludes file entries under [BOOT]/ only when their size is greater than 4 GiB − 1.
  • Falls back to the existing extraction behavior if the scan cannot start or finish, while retaining small boot entries.
src/libdbm/util/sevenzip.cpp
src/libdbm/util/sevenzip.h
Exposes the parser for unit testing and adds coverage for format compatibility and size filtering.
  • Tests detection of an oversized synthetic [BOOT] entry.
  • Tests that old-format output and small [BOOT] entries produce no exclusions.
src/tests/sevenziptest.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: LiHua000, lzwind

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

AI 代码审查报告

项目: linuxdeepin/deepin-boot-maker
PR: #136
提交信息: fix: exclude oversize El Torito [BOOT] entry during iso extraction
审查模式: 全量分析(GitHub PR)


总体评分:97 分

维度 评分 满分 结果
语法逻辑 22 25 ✓ 通过
代码质量 25 25 ✓ 通过
代码性能 20 20 ✓ 通过
代码安全 30 30 ✓ 通过
总分 97 100 优秀

审查结论: 代码审查通过

代码实现了排除超限 El Torito [BOOT] 条目的功能,逻辑清晰,注释完整,无安全漏洞。仅存在 waitForStarted/waitForFinished 无超时的轻微问题,与现有代码风格一致。


需求分析

原始需求: 修复大型 ISO 镜像制作启动 U 盘时,El Torito [BOOT] 条目超过 FAT32 单文件大小限制(4GiB-1)导致提取失败的问题。方案:在提取前扫描 7z l -slt 输出,排除超过限制的 [BOOT] 条目;兼容旧版 p7zip 和新版 7-Zip;扫描失败时回退到不排除的行为。

关联 Bug: https://pms.uniontech.com/bug-view-377229.html(无权限访问)

代码目的匹配: 代码实现与 PR 描述和 commit message 目的完全一致——解析 7z -slt 输出、检测超限 [BOOT] 条目、在提取时排除这些条目、失败时回退。


修改文件

文件 变更 说明
src/libdbm/util/sevenzip.cpp +73/-1 新增 parseOversizeBootPaths()oversizeBootPaths() 方法,修改 extract()
src/libdbm/util/sevenzip.h +11/-1 新增方法声明,添加 QStringList 头文件
src/tests/sevenziptest.cpp +61/-1 新增 3 个测试用例

详细分析

1. 语法逻辑(22/25)✓ 语法正确,逻辑清晰

代码逻辑分析:

  1. parseOversizeBootPaths() 方法(第 63-106 行):解析 7z l -slt 输出,使用 flush() lambda 处理条目边界,检测以 [BOOT]/ 开头且超过 FAT32 限制(4294967295 字节)的文件条目。解析逻辑正确,兼容旧版 p7zip 和新版 7-Zip 输出格式。

  2. oversizeBootPaths() 方法(第 108-128 行):运行 7z l -slt <archive> 命令,获取超限 [BOOT] 路径列表。失败时回退到空列表(不排除任何条目),保证向后兼容。

  3. extract() 方法(第 130-190 行):在提取前调用 oversizeBootPaths() 获取超限条目,为每个条目添加 -x!<path> 排除参数。与现有提取逻辑集成正确。

潜在问题:

  1. src/libdbm/util/sevenzip.cpp 第 118 行,SevenZip::oversizeBootPaths() 函数中 waitForStarted(-1)waitForFinished(-1) 使用无限超时,如果 7z 进程挂起将导致应用程序无限阻塞。建议设置合理的超时时间(如 30 秒/60 秒)。此问题与现有代码风格一致(extract() 第 171 行、check() 第 202 行同样使用 -1),但新代码引入了新的阻塞点。(轻微问题 -3 分)

2. 代码质量(25/25)✓ 代码结构清晰,注释完整

代码质量分析:

  • 注释完整性(5/5): 代码注释非常完善。parseOversizeBootPaths() 注释了 FAT32 限制值和条目边界检测逻辑;oversizeBootPaths() 注释了回退行为和 LANG 环境变量说明;extract() 中的修改注释了 El Torito boot image 背景、7-Zip 通配符行为说明。头文件中方法声明也有完整文档注释。
  • 代码重复(5/5): 无重复代码。parseOversizeBootPaths 设为 static 方法便于复用和测试。
  • 结构合理性(5/5): 关注点分离良好——解析逻辑(parseOversizeBootPaths)与进程管理(oversizeBootPaths)分离;parseOversizeBootPaths 为 static 方法可独立测试。
  • 调试信息清理(5/5): 使用 qInfo()qWarning() 进行适当日志记录,日志级别使用合理。无残留调试代码。

测试覆盖: 新增 3 个测试用例覆盖了:新版 7-Zip 格式超限条目检测、旧版 p7zip 格式兼容、小条目(低于限制)保留。测试用例设计合理。


3. 代码性能(20/20)✓ 性能良好,资源使用合理

性能分析:

  • 7z l -slt 命令仅读取归档索引,不解压数据,执行速度快。
  • split('\n') 逐行解析对于典型 ISO 镜像(数百到数千条目)性能可接受。
  • startsWith() 检查为 O(1) 操作,高效。
  • flush() lambda 无额外开销。
  • 额外的进程调用(7z l -slt)是功能需要,且为一次性操作。
  • QProcess 为局部变量,自动清理,无资源泄漏。

4. 代码安全(30/30)✓ 存在0个安全漏洞

安全分析:

  • 命令注入: 无风险。使用 QProcess::start() 参数列表方式启动进程,不经过 shell 解析。
  • 路径遍历: 无风险。解析的路径仅用作 7z 排除参数(-x!),不用于文件系统访问。
  • 通配符注入: 低风险。7-Zip 的 -x! 仅将 *? 视为通配符,[] 按字面匹配。恶意 ISO 中的 [BOOT] 路径若包含 *? 可能匹配更多文件,但仅影响提取排除范围,不构成安全漏洞。
  • 硬编码凭证: 无。
  • 敏感信息泄露: 日志仅输出文件路径和大小,无敏感信息。
  • 输入验证: toLongLong() 使用成功标志验证,空值不会误判为有效大小。

安全漏洞详情: 未发现安全漏洞

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个


改进建议

建议 1:为 waitForStarted/waitForFinished 设置超时时间

文件:src/libdbm/util/sevenzip.cpp,第 118 行,函数 SevenZip::oversizeBootPaths

当前代码使用无限超时,如果 7z 进程异常挂起会导致应用阻塞:

// 修改前:
if (!listProcess.waitForStarted(-1) || !listProcess.waitForFinished(-1)) {

// 修改后:
if (!listProcess.waitForStarted(30000) || !listProcess.waitForFinished(60000)) {
    qWarning() << "scan iso timed out, skip [BOOT] exclusion:" << listProcess.errorString();
    return result;
}

本报告由 AI 代码审查工具自动生成

@LiHua000

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
deepin-bot Bot merged commit 742f870 into linuxdeepin:master Sep 16, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants