Repository navigation
fix: correct fprintf escapes and add bounds guard - #887
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe PR fixes incorrectly escaped D-Bus connection diagnostics and adds a local guard against insufficient sysfs path segments before indexing, with review focus on error-output formatting, invalid-path behavior, and preserving normal device wake-up flow. Sequence diagram for guarded device wake-up pathsequenceDiagram
participant Caller
participant DBusWakeupInterface
participant InputInterface
Caller->>DBusWakeupInterface: setWakeupMachine(unique_id, wakeup)
DBusWakeupInterface->>DBusWakeupInterface: pathList.size()
alt fewer than 2 path segments
DBusWakeupInterface-->>Caller: false
else valid path segments
DBusWakeupInterface->>InputInterface: call(SetWakeupDevices, busPath, state)
InputInterface-->>DBusWakeupInterface: result
DBusWakeupInterface-->>Caller: wake-up result
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: [] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// 当前代码已正确修复,无需额外修改。 // 边界检查示例(已正确实现): // if (pathList.size() < 2) // return false; // QString curPath = pathList[pathList.size() - 2];本报告由 AI 代码审查工具自动生成 |
1. Root cause: fprintf error strings in DBusEnableInterface and DBusWakeupInterface used /n and /t instead of \n and \t escape sequences, causing error output to not format with newlines or indentation 2. Fix: corrected three fprintf calls to use \n and \t standard C escape sequences for proper error message formatting 3. Root cause: pathList[pathList.size()-2] access lacked a local bounds guard, risking out-of-bounds access if entry validation is removed or refactored in the future 4. Fix: added local if (pathList.size() < 2) return false guard before the index access as defensive programming Influence: 1. Test D-Bus connection failure to verify error output formatting 2. Test setWakeupMachine with various sysfs path segmentations 3. Verify normal device wake-up functionality has no regression fix: 修复fprintf转义错误并增加越界防护 1. 根因:DBusEnableInterface和DBusWakeupInterface中fprintf 错误字符串误用/n和/t而非\n和\t转义序列,导致错误输出 无法正确换行和缩进 2. 方案:修正三处fprintf调用,使用\n和\t标准C转义序列, 恢复错误消息的正确格式化 3. 根因:pathList[pathList.size()-2]索引访问缺少局部越界 防护,若未来重构移除入口校验将存在越界风险 4. 方案:在索引访问前增加局部if (pathList.size() < 2) return false校验,作为防御性编程措施 Influence: 1. 测试D-Bus连接失败场景,验证错误输出格式正确 2. 测试setWakeupMachine在各种sysfs路径分段下的行为 3. 验证正常设备唤醒功能无回归 PMS: BUG-6206
b746317 to
b599166
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, lzwind 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 |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
fix: correct fprintf escapes and add bounds guard
DBusWakeupInterface used /n and /t instead of \n and \t escape
sequences, causing error output to not format with newlines or
indentation
escape sequences for proper error message formatting
bounds guard, risking out-of-bounds access if entry validation
is removed or refactored in the future
before the index access as defensive programming
Influence:
fix: 修复fprintf转义错误并增加越界防护
错误字符串误用/n和/t而非\n和\t转义序列,导致错误输出
无法正确换行和缩进
恢复错误消息的正确格式化
防护,若未来重构移除入口校验将存在越界风险
return false校验,作为防御性编程措施
Influence:
PMS: BUG-6206
Summary by Sourcery
Improve D-Bus error reporting and harden wake-up device path validation against malformed paths.
Bug Fixes:
Chores: