Repository navigation
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR fixes four edge cases by aligning packet-loss interpretation with expected online semantics, terminating installer control flow after dpkg-lock timeouts, cleaning up IPP requests on CUPS connection failures, and bounding URI encoding to preserve NUL termination. Review should focus on packet-loss behavior, ensuring timeout failures never invoke the real install operation, validating cleanup across printer failure paths, and testing URI construction at buffer limits with special characters. Sequence diagram for dpkg lock timeout handlingsequenceDiagram
participant Caller
participant Installer as DriverInstaller_or_DebInstaller
participant Dpkg
participant InstallOperation
Caller->>Installer: installPackage(package)
Installer->>Dpkg: check lock
alt dpkg lock times out
Dpkg-->>Installer: timeout
Installer-->>Caller: installFinished(false)
Note over Installer,InstallOperation: return prevents doOperate()
else lock available
Dpkg-->>Installer: available
Installer->>InstallOperation: doOperate()
end
Sequence diagram for printer enable failure cleanupsequenceDiagram
participant Caller
participant ControlInterface
participant CUPS
participant IPP
Caller->>ControlInterface: enablePrinter(hclass, name)
ControlInterface->>IPP: ippAddString(request, ...)
ControlInterface->>CUPS: cupsServer()
alt CUPS server unavailable
CUPS-->>ControlInterface: null
ControlInterface->>IPP: ippDelete(request)
ControlInterface-->>Caller: false
else HTTP connection fails
ControlInterface->>CUPS: httpConnect2(host, port, ...)
CUPS-->>ControlInterface: null
ControlInterface->>IPP: ippDelete(request)
ControlInterface-->>Caller: false
end
Flow diagram for network online detectionflowchart TD
A[Measure packet loss] --> B{received packet loss is 0%?}
B -->|Yes| C[Return online]
B -->|No| D[Return offline]
D --> E[Do not start online-dependent operation]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ❌评价: 存在逻辑缺陷 ❌ 不通过 潜在问题: 建议: ['在debinstaller.cpp的uninstallPackage函数中,emit installFinished(false)之后添加return语句,与installPackage的修复保持一致'] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ['对installPackage和uninstallPackage中相同的dpkg锁超时模式进行统一修复,确保两处都添加return语句'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: ['在construct_uri函数开头添加 if (buflen == 0) return; 的前置检查,防止无符号整数下溢'] 💡 改进建议代码示例// 修复1: debinstaller.cpp - uninstallPackage函数添加return语句
void DebInstaller::uninstallPackage(const QString &packagename)
{
qCDebug(appLog) << "Uninstalling package:" << packagename;
if (Utils::isFileLocked("/var/lib/dpkg/lock")) {
if (m_iRuningTestCount < MAX_DPKGRUNING_TEST) {
QTimer::singleShot(TEST_TIME_INTERVAL, this, [&] {
uninstallPackage(packagename);
m_iRuningTestCount++;
});
return;
} else {
emit errorOccurred("Dpkg locked ,time out");
emit installFinished(false);
return; // 添加return,防止fall-through到doOperate
}
}
doOperate(packagename, false);
}
// 修复2: controlinterface.cpp - construct_uri添加buflen==0防御性检查
void ControlInterface::construct_uri(char *buffer, size_t buflen, const char *base, ...)
{
if (buflen == 0) return; // 防止无符号整数下溢
// ... 原有逻辑
}本报告由 AI 代码审查工具自动生成 |
1. Root cause: DriverInstallerApt::isNetworkOnline used != 0 on packet loss rate, treating packet loss > 0 as online (inverted logic) 2. Fix: change comparison to == 0 so 0% loss means online, matching DriverInstaller::isNetworkOnline semantics 3. Root cause: DriverInstaller/DebInstaller::installPackage missing return after emit finished(false) in dpkg lock timeout branch, control flow falls through to doOperate() starting real install 4. Fix: add return statement after emit in both installPackage methods 5. Root cause: enablePrinter early-return paths (cupsServer null, httpConnect2 failed) did not call ippDelete(request), leaking ipp_t 6. Fix: add ippDelete(request) before each early return false 7. Root cause: construct_uri loop condition allowed d to reach buffer+buflen, NUL termination check failed when buffer exactly full 8. Fix: reserve 1 byte for NUL by changing loop to d < buffer+buflen-1 and percent-encoding check to d+3 < buffer+buflen Log: fix network online detection and dpkg lock timeout handling Influence: 1. Verify network online/offline detection with various packet loss rates 2. Test dpkg lock timeout scenario does not trigger real installation 3. Test enablePrinter/disablePrinter with CUPS server unavailable 4. Test printer URI construction with long names and special characters fix: 修复网络检查逻辑反转、dpkg锁控制流穿透、内存泄漏和URI终止问题 1. 根因:DriverInstallerApt::isNetworkOnline 对丢包率使用 != 0,丢包率>0 时判定为在线,逻辑与预期相反 2. 方案:将比较改为 == 0,丢包率为0时返回在线,与 DriverInstaller 一致 3. 根因:DriverInstaller/DebInstaller::installPackage 在 dpkg 锁超时分支 emit finished(false) 后缺少 return,控制流穿透到 doOperate 启动安装 4. 方案:在两个 installPackage 的 emit 后添加 return 语句 5. 根因:enablePrinter 早退路径(cupsServer 空/httpConnect2 失败)未调用 ippDelete(request),每次调用泄漏 ipp_t 结构 6. 方案:在每条早退 return false 前添加 ippDelete(request) 7. 根因:construct_uri 循环条件允许 d 到达 buffer+buflen,缓冲区填满时 NUL 终止检查失败,返回未终止字符串 8. 方案:循环条件改为 d < buffer+buflen-1 保留 NUL 空间,百分号编码 检查改为 d+3 < buffer+buflen Log: 修复网络在线检测和dpkg锁超时处理问题 Influence: 1. 验证不同丢包率下网络在线/离线检测是否正确 2. 测试 dpkg 锁超时场景不会触发真实安装 3. 测试 CUPS 服务器不可用时 enablePrinter/disablePrinter 无泄漏 4. 测试长打印机名和特殊字符的 URI 构造是否正确终止
The license-check CI (SPDX Header Validation) requires source files that were created in earlier years and are still being modified to carry a copyright year range ending with the current year. Extend the SPDX-FileCopyrightText ranges of debinstaller.cpp, driverinstaller.cpp and driverinstallerapt.cpp (2019 ~ 2023 / 2019 ~ 2025) so the end year covers 2026 and the SPDX summary reports 0 failures.
|
TAG Bot New tag: 6.0.75 |
fix: fix network check, dpkg lock flow, memory leak and uri term
loss rate, treating packet loss > 0 as online (inverted logic)
DriverInstaller::isNetworkOnline semantics
return after emit finished(false) in dpkg lock timeout branch,
control flow falls through to doOperate() starting real install
httpConnect2 failed) did not call ippDelete(request), leaking ipp_t
buffer+buflen, NUL termination check failed when buffer exactly full
and percent-encoding check to d+3 < buffer+buflen
Log: fix network online detection and dpkg lock timeout handling
Influence:
fix: 修复网络检查逻辑反转、dpkg锁控制流穿透、内存泄漏和URI终止问题
时判定为在线,逻辑与预期相反
emit finished(false) 后缺少 return,控制流穿透到 doOperate 启动安装
ippDelete(request),每次调用泄漏 ipp_t 结构
NUL 终止检查失败,返回未终止字符串
检查改为 d+3 < buffer+buflen
Log: 修复网络在线检测和dpkg锁超时处理问题
Influence:
Summary by Sourcery
Fix network status detection, package-installation timeout handling, printer resource cleanup, and URI buffer termination.
Bug Fixes: