Skip to content

fix(tabbar): guard out-of-range index in fuzz cases - #740

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
pppanghu77:fix/383519-fuzz-oob-guard-master
Nov 20, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
pppanghu77:fix/383519-fuzz-oob-guard-master

Conversation

@pppanghu77

@pppanghu77 pppanghu77 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

修复(tabbar): 修复模糊测试发现的越界索引问题

Log: 修复安全专项模糊测试发现的标签栏越界写与越界读问题
Bug: https://pms.uniontech.com/bug-view-383519.html
PMS: BUG-383519

改动内容 / Changes

  • Tabbar::updateTab() 写入 m_tabPaths/m_tabTruePaths 前增加越界校验,修复 CWE-787 越界写 / Bounds check before writing m_tabPaths/m_tabTruePaths in updateTab() (CWE-787)
  • Tabbar::handleTabIsRemoved() 读取 m_tabPaths.at() 前增加越界校验,修复 CWE-125 越界读 / Bounds check before m_tabPaths.at() in handleTabIsRemoved() (CWE-125)
  • 注:data() 与 tabSizeHint() 两处 master 现有代码已带防护(索引校验 / 除零不可达),无需改动

验证 / Verification

Summary by Sourcery

Guard tab operations against invalid indices to eliminate fuzzing-discovered out-of-bounds access vulnerabilities.

Bug Fixes:

  • Prevent out-of-range tab indices from causing out-of-bounds writes during tab updates.
  • Prevent out-of-range tab indices from causing out-of-bounds reads when removing tabs.

@sourcery-ai

sourcery-ai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Guard tab updates and removals against invalid indices before accessing the tab-path list.

  • src/controls/tabbar.cpp L317-322, L993-998

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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/controls/tabbar.cpp" line_range="318" />
<code_context>
                    << "file:" << QFileInfo(filePath).fileName()
                    << "new name:" << tabName;
+
+    if (index < 0 || index >= m_tabPaths.count()) {
+        qCWarning(appLog) << "Invalid index for updateTab:" << index;
+        return;
</code_context>
<issue_to_address>
**Save-as paths become inconsistent**

When a wrapper remains registered under its old path but that path is absent from the tab bar, `updateTab()` returns without changing the tab, while `Window::updateSaveAsFileName()` and `Window::updateSabeAsFileNameTemp()` continue changing the wrapper path and map key, leaving the tab on the old path and its wrapper on the new one.

Have `updateTab()` report failure and make both save-as callers avoid rekeying the wrapper unless the tab update succeeds.

Also at `src/controls/tabbar.cpp:320`.
</issue_to_address>

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

Comment thread src/controls/tabbar.cpp
<< "file:" << QFileInfo(filePath).fileName()
<< "new name:" << tabName;

if (index < 0 || index >= m_tabPaths.count()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Save-as paths become inconsistent

When a wrapper remains registered under its old path but that path is absent from the tab bar, updateTab() returns without changing the tab, while Window::updateSaveAsFileName() and Window::updateSabeAsFileNameTemp() continue changing the wrapper path and map key, leaving the tab on the old path and its wrapper on the new one.

Have updateTab() report failure and make both save-as callers avoid rekeying the wrapper unless the tab update succeeds.

Also at src/controls/tabbar.cpp:320.

Prompt for AI agents
In `src/controls/tabbar.cpp` at line 318:

**Save-as paths become inconsistent**

When a wrapper remains registered under its old path but that path is absent from the tab bar, `updateTab()` returns without changing the tab, while `Window::updateSaveAsFileName()` and `Window::updateSabeAsFileNameTemp()` continue changing the wrapper path and map key, leaving the tab on the old path and its wrapper on the new one.

Have `updateTab()` report failure and make both save-as callers avoid rekeying the wrapper unless the tab update succeeds.

Also at `src/controls/tabbar.cpp:320`.

- Add bounds check in Tabbar::updateTab() before writing m_tabPaths/m_tabTruePaths to fix CWE-787 out-of-bounds write
- Add bounds check in Tabbar::handleTabIsRemoved() before reading m_tabPaths.at() to fix CWE-125 out-of-bounds read

修复(tabbar): 修复模糊测试发现的越界索引问题

- Tabbar::updateTab() 写入 m_tabPaths/m_tabTruePaths 前增加越界校验,修复 CWE-787 越界写
- Tabbar::handleTabIsRemoved() 读取 m_tabPaths.at() 前增加越界校验,修复 CWE-125 越界读

Log: 修复安全专项模糊测试发现的标签栏越界写与越界读问题(data()/tabSizeHint() 两处已在先前提交中带防护)
Bug: https://pms.uniontech.com/bug-view-383519.html
PMS: BUG-383519
@pppanghu77
pppanghu77 force-pushed the fix/383519-fuzz-oob-guard-master branch from c4fef7e to 30dddca Compare November 20, 2026 08:44
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

@pppanghu77

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
deepin-bot Bot merged commit cfdb53f into linuxdeepin:master Nov 20, 2026
20 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