已开启
告警修复 #5561
已开启
王旭创建于 2 天前
王旭
王旭
2 天前

一、内容说明(相关的Issue)

二、建议测试周期和提测地址

建议测试完成时间:xxxx.xx.xx
投产上线时间:xxxx.xx.xx
提测地址:CI环境/压测环境
测试账号:

三、变更内容

  • 3.1 关联PR列表

  • 3.2 数据库和部署说明

    1. 常规更新
    2. 重启unicorn
    3. 重启sidekiq
    4. 迁移任务:是否有迁移任务,没有写 "无"
    5. rake脚本:bundle exec xxx RAILS_ENV = production;没有写 "无"
  • 3.4 其他技术优化内容(做了什么,变更了什么)

    • 重构了 xxxx 代码
    • xxxx 算法优化
  • 3.5 废弃通知(什么字段、方法弃用?)

  • 3.6 后向不兼容变更(是否有无法向后兼容的变更?)

四、研发自测点(自测哪些?冒烟用例全部自测?)

自测测试结论:

五、测试关注点(需要提醒QA重点关注的、可能会忽略的地方)

检查点:

需求名称 是否影响xx公共模块 是否需要xx功能 需求升级是否依赖其他子产品
xxx 需要 不需要

接口测试:

性能测试:

并发测试:

其他:

likedislike
合并受阻
openharmony_ciopenharmony_ci成员
2 天前 添加了label:waiting_on_author
openharmony_ci
openharmony_ci成员
2 天前 评论:

感谢提交 Pull Requests!如果您提交的PR已经开发完毕,请评论 "start build" 触发门禁,更多交互操作,请访问OpenHarmony社区支持命令清单。如果需要调整订阅PR、Issue的变更状态,请访问订阅链接


Thanks for submitting the pull request. If your Pull Request has already been developed, you can leave a "start build" comment to trigger the gated system. For more commands, please visit OpenHarmony Command List. If you need to change the subscription of a Pull Request or Issue, please visit the link.

likedislike
openharmony_ciopenharmony_ci成员
2 天前 添加了label:dco检查成功
王旭王旭
2 天前 关联了issue:[Bug]: 告警修复
王旭
王旭
2 天前 评论:

start build

likedislike
openharmony_ci
openharmony_ci成员
2 天前 评论:

首次触发
门禁构建开始,包含静态检查、代码编译和测试【hispark_pegasus_3863编译, hispark_taurus_Linux编译, x86_64_virt编译, hispark_pegasus_3863测试, dayu600_7885测试, dayu200编译, ohos-host_mini_tdd编译, dayu200测试, hispark_pegasus编译, hispark_pegasus测试, dayu600_7885编译, dayu200_tdd编译, master_inner_build编译】,预计在60分钟内完成,门禁结果会同步发送到注册邮箱。您可以通过如下链接跟踪门禁进展:http://dcp.openharmony.cn/workbench/cicd/detail/6a8664ea64650f998bc9490c/runlist

likedislike
LisaMessi
2 天前 评论:

PR 审查报告:#5561 - 告警修复

仓库:OpenHarmony/communication_wifi
PR 地址https://gitcode.com/openharmony/communication_wifi/merge_requests/5561
作者:王旭 (tradeWindToNorth)
目标分支:master
PR SHA780ae598d2f550f7805cb2db27ff3ed5db98691c
状态:open
标签waiting_on_authordco检查成功

CI 状态

  • ✅ DCO 检查成功
  • ✅ 冲突检查通过

变更概要

本 PR 修复静态检查告警(1 个文件,+1/-1):GetConnectedStationInfo 循环增加 staNumber 上限约束。

bool DhcpdInterface::GetConnectedStationInfo(const std::string &ifaceName, std::...)
{
    ...
    GetConnectedStaInfo(ifaceName, staNumber, staInfos, &staSize);
-    for (int i = 0; i < staSize; i++) {
+    for (int i = 0; i < staSize && i < staNumber; i++) {
        StationInfo info;
        info.deviceName = staInfos[i].deviceName;
        info.bssid = staInfos[i].macAddr;

问题详情

💡建议

1. 修复方向正确,需确认 staNumber/staSize 语义

位置wifi/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper/dhcpd_interface.cppGetConnectedStationInfo

描述GetConnectedStaInfo(ifaceName, staNumber, staInfos, &staSize) 中,staNumber 通常为数组容量(输入),staSize实际填充数量(输出)。正常情况下 staSize <= staNumber 恒成立;静态检查无法证明该不变量,故告警 staInfos[i] 可能越界(若 staSize > staNumber 将发生缓冲区越界读)。新增 i < staNumber 约束后:

  • staSize <= staNumber 正常时:行为不变;
  • staSize > staNumber 异常时:只遍历前 staNumber 项,避免越界读

影响:修复消除了潜在越界读;正常路径无行为变化。防御性截断(丢弃多余项)在异常场景下可接受。

修复建议:建议在异常场景(staSize > staNumber)补一条告警日志,便于现场定位:

GetConnectedStaInfo(ifaceName, staNumber, staInfos, &staSize);
if (staSize > staNumber) {
    WIFI_LOGE("staSize %{public}d exceed staNumber %{public}d", staSize, staNumber);
}
for (int i = 0; i < staSize && i < staNumber; i++) {
    ...
}

2. 可读性优化(可选)

i < staSize && i < staNumber 可等价改写为 i < std::min(staSize, staNumber),语义更直观(需注意 staSize 类型,若为指针输出需先取值)。可接受现状。

3. 无测试

建议补充 staSize > staNumber 场景的单元测试(mock GetConnectedStaInfo 返回值),验证不越界且结果正确。


总体评分

维度 评分 说明
功能正确性 8/10 修复正确,正常路径无回归
代码质量 7/10 最小化改动
安全性 8/10 消除潜在越界读
可维护性 7/10 改动清晰
测试充分性 5/10 无测试
综合评分 7/10

审查结论

建议操作:✅ 可以合并

说明:

  • 问题 1 为本 PR 核心修复点,方向正确、防御有效;
  • 建议补充异常场景日志与测试作为后续增强,不阻塞合并。

优点:

  • 精准消除潜在缓冲区越界读(staInfos[i]staNumber 容量约束)
  • 变更最小(1 文件,+1/-1)
  • DCO 检查通过
likedislike
openharmony_ciopenharmony_ci成员
2 天前 添加了label:编译成功
openharmony_ciopenharmony_ci成员
2 天前 添加了label:静态检查成功
openharmony_ciopenharmony_ci成员
2 天前 添加了label:冒烟测试成功
openharmony_ciopenharmony_ci成员
2 天前 通过测试
openharmony_ci
openharmony_ci成员
2 天前 评论:

代码门禁通过
您可以通过如下链接查看门禁报告:http://dcp.openharmony.cn/workbench/cicd/detail/6a8664ea64650f998bc9490c/runlist

静态检查:

# check type result report
1 codeCheck pass >>>

编译测试:
# Device build result test result package
1 hispark_taurus_Linux success NA >>>
2 dayu200 success success >>>
3 dayu200_tdd success NA >>>
4 hispark_pegasus success success >>>
5 master_inner_build success(IGNORE) NA >>>
6 ohos-host_mini_tdd success NA >>>
7 dayu600_7885 success success >>>
8 x86_64_virt success NA >>>
9 hispark_pegasus_3863 success success >>>

likedislike
openharmony_ciopenharmony_ci成员
2 天前 删除了label:waiting_on_author
openharmony_ciopenharmony_ci成员
2 天前 添加了label:waiting_for_review
openharmony_ci
openharmony_ci成员
2 天前 评论:

您好,Committer @wshixjr @bjtu_wujun_transportation @f00651013 @chengguohong ,请分配检视人员检视该PR,可以通过命令"assign [@someone_id]"分配检视人员,也可以直接评论"assign"分配给自己进行检视。


Hello, Committer @wshixjr @bjtu_wujun_transportation @f00651013 @chengguohong . Please assign someone to review the PR. You can assign a reviewer by using the command "assign [@someone_id]", or you can comment "assign" to review the PR by yourself.

likedislike
王旭王旭
2 天前 删除了关联的issue:[Bug]: 告警修复
王旭王旭
2 天前 关联了issue:[Bug]: CDE 告警修复
王旭
王旭
2 天前 评论:

start build

likedislike
openharmony_ciopenharmony_ci成员
2 天前 删除了label:编译成功
openharmony_ciopenharmony_ci成员
2 天前 删除了label:静态检查成功
openharmony_ciopenharmony_ci成员
2 天前 删除了label:冒烟测试成功
openharmony_ci
openharmony_ci成员
2 天前 评论:

首次触发
门禁构建开始,包含静态检查、代码编译和测试【hispark_pegasus_3863编译, master_inner_build编译, hispark_taurus_Linux编译, hispark_pegasus测试, dayu600_7885编译, dayu200测试, dayu600_7885测试, hispark_pegasus_3863测试, dayu200编译, ohos-host_mini_tdd编译, dayu200_tdd编译, x86_64_virt编译, hispark_pegasus编译】,预计在60分钟内完成,门禁结果会同步发送到注册邮箱。您可以通过如下链接跟踪门禁进展:http://dcp.openharmony.cn/workbench/cicd/detail/6a869d2564650f998bdc3b92/runlist

likedislike
openharmony_ciopenharmony_ci成员
2 天前 添加了label:编译成功
openharmony_ciopenharmony_ci成员
2 天前 添加了label:静态检查成功
openharmony_ciopenharmony_ci成员
2 天前 添加了label:冒烟测试成功
openharmony_ciopenharmony_ci成员
2 天前 通过测试
openharmony_ci
openharmony_ci成员
2 天前 评论:

代码门禁通过
您可以通过如下链接查看门禁报告:http://dcp.openharmony.cn/workbench/cicd/detail/6a869d2564650f998bdc3b92/runlist

静态检查:

# check type result report
1 codeCheck pass >>>

编译测试:
# Device build result test result package
1 hispark_taurus_Linux success NA >>>
2 dayu200 success success >>>
3 dayu200_tdd success NA >>>
4 hispark_pegasus success success >>>
5 master_inner_build success(IGNORE) NA >>>
6 ohos-host_mini_tdd success NA >>>
7 dayu600_7885 success success >>>
8 x86_64_virt success NA >>>
9 hispark_pegasus_3863 success success >>>

likedislike
openharmony_ci
openharmony_ci成员
2 天前 评论:

您好,Committer @wshixjr @bjtu_wujun_transportation @f00651013 @chengguohong ,请分配检视人员检视该PR,可以通过命令"assign [@someone_id]"分配检视人员,也可以直接评论"assign"分配给自己进行检视。


Hello, Committer @wshixjr @bjtu_wujun_transportation @f00651013 @chengguohong . Please assign someone to review the PR. You can assign a reviewer by using the command "assign [@someone_id]", or you can comment "assign" to review the PR by yourself.

likedislike