Welcome To openEuler Community
Hey @liu-haodong142 , 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 ,


已确认该问题并提交修复 PR:https://atomgit.com/src-openeuler/file/pull/96(目标 openEuler-26.09)。
问题确认:在 file 5.45 上用 ASan 复现成功,栈越界读位置与报告一致:
AddressSanitizer: stack-buffer-overflow READ of size 37- 栈:
strcasestr <- cdf_app_to_mime (readcdf.c:130) <- cdf_check_summary_info (readcdf.c:411) <- file_trycdf
根因:cdf_check_summary_info() 把 CDF 目录名拷入 32 字节栈缓冲(无 NUL 空间)后传给 cdf_app_to_mime(),后者用 strcasestr() 扫描,未终止的 32 字符目录名导致越界读。
修复:缓冲区扩为 33 字节、拷贝上限减一、末尾置 NUL(backport 上游 commit 029e5bae)。
验证:修复后 PoC 无 ASan 报错(输出 application/vnd.ms-office);合法目录名(WordDocument)样本修复前后输出一致;上游测试套件 71 例无新增差异。


问题描述
src/readcdf.c的cdf_check_summary_info()将 CDF(OLE2)目录项名称(最多 32 个 UTF-16 字符)逐字符拷贝到char name[__arraycount(d->d_name)](32 字节)栈缓冲区,未写入结尾 NUL,随后把该缓冲区传入cdf_app_to_mime()。该函数使用strcasestr()对目录名做子串匹配,会越过 32 字节缓冲区继续读取,造成栈越界读(CWE-125 / CWE-170)。file/libmagic常用于扫描不受信任文件,恶意 CDF 文件可触发该问题。影响范围
file --mime-type)复现
基于 file 5.48 官方 tarball 使用 ASan 构建,构造 5632 字节 PoC CDF(目录项名称由 32 个
A的 UTF-16 编码组成且无 NUL,SummaryInformation 流属性类型为CDF_NULL),执行:修复前 ASan 报告:
修复
回移上游提交,将栈缓冲区扩大 1 字节并在拷贝后显式写入
'\0',确保传给strcasestr()的字符串以 NUL 结尾。上游提交:https://github.com/file/file/commit/029e5bae7362e71671b3e1f316d4f3936d8a7819
修复后行为:同一 PoC 不再触发 ASan,输出
application/vnd.ms-office;正常文件类型识别结果与修复前一致。openEuler 侧进展
已按 backport 规范生成补丁
backport-cdf-name-nul-terminate.patch,在 master 分支(5.48-2)验证并推送,PR 随后提交。上游未为此分配 CVE,属普通缺陷修复。