已合并
tftpc.c存在缓冲区越界读写 #1398
tftpc.c存在缓冲区越界读写 #1398
已合并
yang-pangyuan创建于 6月16日
yang-pangyuan成员
6月16日

相关的Issue

https://gitcode.com/openharmony/kernel_liteos_a/issues/1086

原因(目的、解决的问题等)

tftpc.c文件中存在缓冲区越界写入。问题出在1649行和1681行的memcpy_s调用处。这两处代码错误地将目标缓冲区的最大容量硬编码为TFTP_MAX_BLK_NUM乘TFTP_BLKSIZE,而没有使用调用者实际分配的缓冲区大小。1436行的ulFileLength参数仅用于表示期望读取或返回的文件长度,并非缓冲区容量限制。安全影响为内存破坏,严重程度为高危。触发条件为:当调用者为szDestMemAddr分配的缓冲区小于硬编码常量TFTP_MAX_BLK_NUM乘TFTP_BLKSIZE时,恶意TFTP服务器只需发送超过实际分配大小但不超过硬编码常量的数据,即可成功触发越界写入。

描述(做了什么,变更了什么)

memcpy_s调用处目标区域大小设置为, 剩余空间大小 = *ulFileLength - ulMemOffset

测试用例(新增、改动、可能影响的功能)

是否涉及对外变更(典型的如:对外API规格变更、新增对外接口等等)

否,不涉及对外变更

是否需要同步至release(如:3.0LTS ... )分支?

likedislike
Pull Request已成功合入, 合并人@openharmony_ci
(感谢 yang-pangyuan 的贡献)
openharmony_ciopenharmony_ci成员
6月16日 添加了label:waiting_on_author
openharmony_ci
openharmony_ci成员
6月16日 评论:

感谢提交 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成员
6月16日 添加了label:dco检查成功
Yyang-pangyuan成员
6月16日 修改标题为 “tftpc.c存在缓冲区越界读写”,原标题为“IssueNo:1”
Yyang-pangyuan成员
6月16日 修改了pull request 的描述
yang-pangyuan成员
6月16日 评论:

start build

likedislike
openharmony_ci
openharmony_ci成员
6月16日 评论:

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

likedislike
openharmony_ciopenharmony_ci成员
6月16日 添加了label:编译成功
openharmony_ciopenharmony_ci成员
6月16日 添加了label:静态检查成功
openharmony_ciopenharmony_ci成员
6月16日 添加了label:冒烟测试成功
openharmony_ciopenharmony_ci成员
6月16日 通过测试
openharmony_ci
openharmony_ci成员
6月16日 评论:

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

静态检查:

# check type result report
1 codeCheck pass >>>

编译测试:
# Device build result test result package
1 hispark_taurus_LiteOS success success >>>
2 master_inner_build success(IGNORE) NA >>>
3 dayu600_7885 success(IGNORE) NA >>>
4 ohos-host success NA >>>
5 ohos-mini success NA >>>
6 arm64_virt success NA >>>
7 ohos_mini_tdd success NA >>>
8 x86_64_virt failed(IGNORE)(compile failed) NA >>>

likedislike
openharmony_ciopenharmony_ci成员
6月16日 删除了label:waiting_on_author
openharmony_ciopenharmony_ci成员
6月16日 添加了label:waiting_for_review
openharmony_ci
openharmony_ci成员
6月16日 评论:

您好,Committer @JerryH1011 @LeonChan525 @zhu-sheng-le ,请分配检视人员检视该PR,可以通过命令"assign [@someone_id]"分配检视人员,也可以直接评论"assign"分配给自己进行检视。


Hello, Committer @JerryH1011 @LeonChan525 @zhu-sheng-le . 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
Zzhu-sheng-le成员
6月16日 通过审查
openharmony_ciopenharmony_ci成员
6月16日 关闭了关联的issue
openharmony_ciopenharmony_ci成员
6月16日 合入了pull request,合并节点 SHA:339944005711f4f1b242fda608f987641130bfd4
openharmony_ciopenharmony_ci成员
6月16日 删除了label:waiting_for_review
openharmony_ciopenharmony_ci成员
6月16日 添加了label:merged
Yyang-pangyuan成员
6月16日 修改了pull request 的描述