Open
backport: NUL terminate CDF directory name passed to cdf_app_to_mime [openEuler-26.09] #96
backport: NUL terminate CDF directory name passed to cdf_app_to_mime [openEuler-26.09] #96
Open
huijing_zhangAdd on 3 days ago
huijing_zhang
huijing_zhang
3 days ago

问题

cdf_check_summary_info() 将 CDF 目录名拷贝到固定 32 字节的栈缓冲区后,未做 NUL 终止就传给 cdf_app_to_mime()(内部使用 strcasestr())。当目录名恰为 32 个字符(UTF-16 64 字节、无 NUL)时,strcasestr() 越界读取栈内存。

对应 issue: #29

根因

readcdf.c cdf_check_summary_info():

char name[__arraycount(d->d_name)];          /* 32 字节,无 NUL 空间 */
for (k = 0; k < sizeof(name); k++)
    name[k] = CAST(char, cdf_tole2(d->d_name[k]));
str = cdf_app_to_mime(name, ...);            /* strcasestr() 越界读 */

上游修复:commit 029e5bae(PR/812: mgl)。

本地验证(file 5.45 + ASan)

触发 PoC(6144 字节 CDF/OLE2 复合文档,目录项名 64 字节 'A' 无 NUL):

  • 修复前:AddressSanitizer: stack-buffer-overflow READ of size 37,栈为 strcasestr <- cdf_app_to_mime (readcdf.c:130) <- cdf_check_summary_info (readcf.c:411) <- file_trycdf,与 issue 报告一致
  • 修复后:无 ASan 报错,输出 application/vnd.ms-office

回归验证:合法目录名(WordDocument + NUL)样本,修复前后输出一致(application/msword / plain 输出相同);上游测试套件 71 例无新增差异(fit-map-data / multiple / regex-eol 3 例差异在未打补丁的原版构建同样出现,为环境时区/魔法文件版本差异,与本补丁无关)。

修复

缓冲区扩为 33 字节、拷贝上限 sizeof(name) - 1、末尾置 '\0'。

说明

本 PR 基于 PR #93(do_core_note PRPSINFO 越界读)之上,spec 变更包含其 P3/Release 6 状态;若 #93 先合入,本 PR 需要 rebase(仅 changelog 行)。

backport 上游 commit 029e5bae7362e71671b3e1f316d4f3936d8a7819。

likedislike
Merge blocked
huijing_zhanghuijing_zhang
3 days ago Created pull request, commit bb22e654
huijing_zhanghuijing_zhang
3 days ago Associated issue: file: CDF 目录名未 NUL 终止导致栈越界读(待 backport 上游 029e5bae)
openeuler-ci-botopeneuler-ci-botCollaborators
3 days ago Set VICTORY2017,mszjaas,swf504,liuzhiqiang26,louhongxiang,kouwq,dragon1147e3 as approver
openeuler-ci-botopeneuler-ci-botCollaborators
3 days ago Added label: sig/Storage
openeuler-ci-bot
openeuler-ci-botCollaborators
3 days ago Comments:

Welcome To openEuler Community

Hey @huijing_zhang , thanks for your contribution to the community.

Bot Usage Manual

I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands. You can self-configure the PR merge rules for this repository. For more details, please refer to Here.

Contact Guide

If you have any questions, please contact the SIG: Storage ,
and any of the maintainers: @VICTORY2017, @dragon1147e3, @kouwq, @liuzhiqiang26, @louhongxiang, @mszjaas, @swf504 ,

likedislike
openeuler-ci-bot
openeuler-ci-botCollaborators
3 days ago Comments:

当前仓库存在以下 保护分支 :

Protected Branch Version Release
master 5.48 1
openEuler-26.09 5.45 5
openEuler-26.09-DevStation 5.45 5
openEuler-24.03-LTS-SP1 5.45 5
openEuler-24.03-LTS-SP3 5.45 5
openEuler-24.03-LTS-SP4 5.45 5
openEuler-24.03-LTS-Next 5.45 5
openEuler-22.03-LTS-SP4 5.41 7
openEuler-20.03-LTS-SP4 5.39 11
openEuler1.0-base 5.38 1
openEuler1.0 5.38 1

评论 /sync <branch1> <branch2> ... 可将当前 PR 修改同步到其它分支(创建同步 PR):
a) 如果当前 PR 是 Open 状态,同步操作将延迟到 PR 被合并时执行
b) 如果当前 PR 已经 Merged,将立即执行同步操作

注意:

  1. /sync 命令可以指定同步到多个分支,仅最后一个 /sync 命令生效
  2. 如果创建的同步 PR 不正确,可通过向同步 PR 的源分支提交轻量级 PR 完善,或使用 /close 命令关闭
likedislike
openeuler-ci-botopeneuler-ci-botCollaborators
3 days ago Added label: openeuler-cla/yes
openeuler-bot
openeuler-botCollaborators
3 days ago Comments:

门禁正在运行, 您可以通过以下链接查看实时门禁检查结果.
若您对门禁结果含义不清晰或者遇到问题不知如何解决,可参考门禁指导手册
门禁入口及编码规范检查: multiarch/src-openeuler/trigger/file/57

likedislike
openeuler-botopeneuler-botCollaborators
3 days ago Added label: ci_processing
openeuler-bot
openeuler-botCollaborators
3 days ago Comments:

aarch64架构构建及构建后检查:multiarch/src-openeuler/aarch64/file/57

likedislike
openeuler-bot
openeuler-botCollaborators
3 days ago Comments:

x86_64架构构建及构建后检查:multiarch/src-openeuler/x86-64/file/57

likedislike
openeuler-botopeneuler-botCollaborators
3 days ago Removed label: ci_processing
openeuler-bot
openeuler-botCollaborators
3 days ago Comments:
Check Name Build Result 详情 Build Details
check_binary_file ✅SUCCESS #57
check_lfsconfig ☑EXCLUDE
check_package_yaml_file ✅SUCCESS
check_repo_in_maintain ✅SUCCESS
check_consistency ✅SUCCESS
check_spec_file ✅SUCCESS
x86_64 check_build ❌FAILED #57
check_install ⚪SKIPPED
check_license ⚪SKIPPED
aarch64 check_build ❌FAILED #57
check_install ⚪SKIPPED
check_license ⚪SKIPPED
likedislike
openeuler-botopeneuler-botCollaborators
3 days ago Added label: ci_failed
openeuler-bot
openeuler-botCollaborators
3 days ago Comments:
likedislike
huijing_zhanghuijing_zhang
3 days ago Pre merge succeeded (commit_id: 72160ab1de668d0f68712040bcdc3a5bea50b864)
huijing_zhanghuijing_zhang
3 days ago Pushed 1 commits:08695e6a-fix patch: use correct hunk line counts and LF endings
huijing_zhanghuijing_zhang
3 days ago Pre merge succeeded (commit_id: dfa44b19f621dbbe0fe192d3cd53c19a4479afd5)
openeuler-ci-botopeneuler-ci-botCollaborators
3 days ago Removed label: openeuler-cla/yes
openeuler-ci-botopeneuler-ci-botCollaborators
3 days ago Added label: stat/needs-squash
openeuler-ci-botopeneuler-ci-botCollaborators
3 days ago Added label: openeuler-cla/yes
openeuler-ci-bot
openeuler-ci-botCollaborators
3 days ago Comments:

CLA Signature Pass

huijing_zhang, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
openeuler-bot
openeuler-botCollaborators
3 days ago Comments:

门禁正在运行, 您可以通过以下链接查看实时门禁检查结果.
若您对门禁结果含义不清晰或者遇到问题不知如何解决,可参考门禁指导手册
门禁入口及编码规范检查: multiarch/src-openeuler/trigger/file/58

likedislike
openeuler-botopeneuler-botCollaborators
3 days ago Removed label: ci_failed
huijing_zhang
huijing_zhang
3 days ago Comments:

check_build 失败根因与修复

经本地 rpmbuild -bp 复现定位:本次提交前 backport-cdf-name-nul-terminate.patch 为 CRLF 行尾且 hunk#2 计数写错(-402,7 +403,8,实际 8 行上下文),在 %autosetup -p1 --fuzz=0 严格模式下应用失败(1 out of 2 hunks FAILED)。

已在 08695e6 重新生成补丁(LF 行尾、计数正确),本地验证:

  • tarball + P1..P4 全链 fuzz=0 应用成功
  • ASan 构建 PoC 无越界报告,输出 application/vnd.ms-office
  • 回归样本仍为 application/msword

push 已触发 CI 重跑,等待结果。

likedislike
openeuler-botopeneuler-botCollaborators
3 days ago Added label: ci_processing
openeuler-bot
openeuler-botCollaborators
3 days ago Comments:

x86_64架构构建及构建后检查:multiarch/src-openeuler/x86-64/file/58

likedislike
openeuler-bot
openeuler-botCollaborators
3 days ago Comments:

aarch64架构构建及构建后检查:multiarch/src-openeuler/aarch64/file/58

likedislike
openeuler-botopeneuler-botCollaborators
3 days ago Removed label: ci_processing
openeuler-bot
openeuler-botCollaborators
3 days ago Comments:
Check Name Build Result 详情 Build Details
check_binary_file ✅SUCCESS #58
check_lfsconfig ☑EXCLUDE
check_package_yaml_file ✅SUCCESS
check_repo_in_maintain ✅SUCCESS
check_consistency ✅SUCCESS
check_spec_file ❌FAILED • file.spec: 本次PR未更新changelog,每次提交都需要添加changelog条目
x86_64 check_build ✅SUCCESS #58
check_install ✅SUCCESS
check_license ✅SUCCESS
aarch64 check_build ✅SUCCESS #58
check_install ✅SUCCESS
check_license ✅SUCCESS
likedislike
openeuler-botopeneuler-botCollaborators
3 days ago Added label: ci_failed
openeuler-bot
openeuler-botCollaborators
3 days ago Comments:

如下为接口变更检查结果,目标分支为openEuler-26.09,请PR提交者check差异信息

Arch Name Check Items Rpm Name Check Result Build Details
compare_package(x86_64) add_rpms ✅SUCCESS #58
delete_rpms ✅SUCCESS
rpm_abi ✅SUCCESS
rpm_cmd ✅SUCCESS
rpm_files ✅SUCCESS
rpm_header ✅SUCCESS
rpm_lib ✅SUCCESS
rpm_provides ✅SUCCESS
rpm_requires ✅SUCCESS
rpm_symbol ✅SUCCESS
compare_package(aarch64) add_rpms ✅SUCCESS #58
delete_rpms ✅SUCCESS
rpm_abi ✅SUCCESS
rpm_cmd ✅SUCCESS
rpm_files ✅SUCCESS
rpm_header ✅SUCCESS
rpm_lib ✅SUCCESS
rpm_provides ✅SUCCESS
rpm_requires ✅SUCCESS
rpm_symbol ✅SUCCESS
likedislike
openeuler-bot
openeuler-botCollaborators
3 days ago Comments:
likedislike