Merged
fix(base64): reject malformed padding that underflows decodeOutLen #2723
fix(base64): reject malformed padding that underflows decodeOutLen #2723
Merged
王子睿Add on 9 days ago
王子睿
王子睿
9 days ago

一:关联的Issue

https://gitcode.com/openharmony/commonlibrary_ets_utils/issues/2556

二:修改原因

收紧 Buffer 内部状态的访问边界,避免构造出超出源视图范围的 Buffer,并校验 Base64 解码的填充和输出长度。

三:修改描述

  • Buffer 的 native 状态移到模块私有的 WeakMap。
  • 构造共享视图前校验偏移和长度,native 层再次核对实际边界。
  • Base64 在计算输出长度前检查输入长度和填充字节数。

四:兼容性领域分析

分析范围为 PR 的完整变更,覆盖 Buffer 的 ArkTS 实现和 native 构造、Base64 同步与异步解码、构建输入及 UT。

  • API 和构建:公开 SDK 声明、模块名和导出接口未变。GN 只补充 Buffer 的 TypeScript 源码和配置作为增量构建输入。UT 调整了畸形 Base64 输入的断言。
  • Buffer 的合法输入:从 Buffer 复制时仍复制有效字节。合法三参数共享视图仍按底层绝对偏移取数据。显式传入 ArrayBuffer 或 SharedArrayBuffer 时仍共享内存。池化 Buffer 的 .buffer 仍返回当前切片的副本。省略长度时保留原默认长度计算,包括小数偏移。切片会保留底层所有者的引用,避免底层存储过早回收。
  • Buffer 的边界和运行时构造:保留负长度和非法偏移的既有范围错误及文案。原先放行的超出源视图或底层存储范围的请求现在被拒绝,报 10200001。直接调用运行时构造器时,ArrayBuffer 或 SharedArrayBuffer 也可省略偏移或长度以创建共享视图。
  • Buffer 的代理和反射:内部状态迁移到 WeakMap,外层 Proxy 无法再通过内部 Symbol 访问或修改状态。普通转发 Proxy 仍可工作,但默认 valueOf 的函数身份变化。自定义 Proxy 若拦截该属性或让其抛错,部分依赖内部状态的方法可能报 401 或传播该异常。
  • Base64:合法输入的编码和解码结果保持一致。过短的带填充输入现在在输出长度计算前终止。同步解码抛出 401,异步解码在工作线程停止解码,并沿用现有 Promise 完成路径。变化集中在畸形输入的处理。

五:CheckList(必填项)

1. 接口功能自检

  • rk3568 推UT文件执行(影响功能的必须执行)
  • xts测试套执行(影响功能的必须执行)

2. 解决问题分类自检 (基于问题维度自检)

3. 接口功能用例看护自检(基于修改的功能点自检)

4. 稳定性专项自检(非Test代码必须执行)

  • 用例验证,门禁构建镜像启动一遍所有应用,无相关的异常出现

5. 压测专项自检

  • 压测填表验证,无相关的异常出现

6. 并发专项自检(taskpool/worker改动必须执行)

  • 图库详情页功能测试
  • 图库相册功能测试:拍几张照片,进入图库相册功能,右上角+号创建新相册,弹窗中选择所有相册,查看是否有内容列表
  • 备忘录图片功能测试:拍几张照片,进入备忘录新增内容,选择添加图片功能,弹窗中选择所有相册,查看是否有内容列表
  • 畅连功能测试:登陆账号,发送30+图片,持续30+轮次
  • 游戏功能测试(消消乐/倩女幽魂/三国志/多乐斗地主/象棋等)
  • 48小时压测
  • wukong压测2小时验证(非Test代码需要)
  • 线程泄露测试(修改涉及线程生命周期需要,执行命令 ps -AT|grep pid|grep OS_TaskWorker|wc -l)

7. 需求上库自检

  • 是否同步合入interface仓的相关d.ts(需求合入用同一个issue)

是否已执行L0用例

六:将上述测试的截图贴到下面

likedislike
Pull Request has been successfully merged by openharmony_ci.
(Thank you for 王子睿's contribution.)
openharmony_ciopenharmony_ciCollaborators
9 days ago Added label: waiting_on_author
openharmony_ci
openharmony_ciCollaborators
9 days ago Comments:

感谢提交 Pull Requests !此PR未通过DCO校验。
校验失败可能原因:

1. 未签署“DCO协议”(开发者原创声明协议),在线签署、查看签署状态。

2. Commits 中未包含 Signed-off-by信息,参考FAQ处理。

修复上述问题后,在PR的评论框输入“check dco” ,单击”评论”,系统将再次进行DCO校验。

当前检测到如下Commits 未包含Signed-off-by信息:


Thanks for submitting a pull request. This pull request has not passed the DCO check.
Possible causes:

1. You have not signed the Developer Certificate of Origin (DCO). Sign the DCO and check DCO status.

2. The commits do not contain the Signed-off-by information. To resolve this issue, see FAQs.

After resolving the preceding issues, enter check dco in the comment box of this pull request and click Comment. The system will check DCO status again.

The following commits do not contain the Signed-off-by information:

likedislike
openharmony_ciopenharmony_ciCollaborators
9 days ago Added label: dco检查失败
王子睿王子睿
9 days ago Force-pushed 1 commits:4509f3e7-fix(base64): reject malformed padding that underflows decodeOutLen
openharmony_ci
openharmony_ciCollaborators
9 days ago Comments:

感谢提交 Pull Requests !此PR未通过DCO校验。
校验失败可能原因:

1. 未签署“DCO协议”(开发者原创声明协议),在线签署、查看签署状态。

2. Commits 中未包含 Signed-off-by信息,参考FAQ处理。

修复上述问题后,在PR的评论框输入“check dco” ,单击”评论”,系统将再次进行DCO校验。

当前检测到如下Commits 未包含Signed-off-by信息:


Thanks for submitting a pull request. This pull request has not passed the DCO check.
Possible causes:

1. You have not signed the Developer Certificate of Origin (DCO). Sign the DCO and check DCO status.

2. The commits do not contain the Signed-off-by information. To resolve this issue, see FAQs.

After resolving the preceding issues, enter check dco in the comment box of this pull request and click Comment. The system will check DCO status again.

The following commits do not contain the Signed-off-by information:

likedislike
170 messages are collapsed here。 See more
weng-changchengweng-changchengCollaborators
22 hours ago Approval passed
openharmony_ciopenharmony_ciCollaborators
22 hours ago Closed associated issue
openharmony_ciopenharmony_ciCollaborators
22 hours ago Merged pull request, merge node SHA: bb356b047f3797727e0115f56bd1a7fdd31059ad
openharmony_ciopenharmony_ciCollaborators
22 hours ago Removed label: waiting_for_review
openharmony_ciopenharmony_ciCollaborators
22 hours ago Added label: merged