Repository navigation
修复DFS大文件索引bug - #11492
修复DFS大文件索引bug#11492LZerro wants to merge 10 commits into
Conversation
📌 Code Review Assignment🏷️ Tag: componentsReviewers: @Maihuanyi Changed Files (Click to expand)
🏷️ Tag: components_libcReviewers: @GorrayLi @mysterywolf Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-06-15 18:08 CST)
📝 Review Instructions
|
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
BernardXiong
left a comment
There was a problem hiding this comment.
Review / 审查
结论 / Conclusion: blocking correctness issue found; please fix the offset arithmetic and add boundary tests before merge.
严重 / Blocking
-
Signed overflow can occur before the new
FSIZE_trange check.Locations:
components/dfs/dfs_v2/src/dfs_file.c:1192-1194components/dfs/dfs_v2/filesystems/elmfat/dfs_elm.c:668-674
SEEK_CURandSEEK_ENDcalculatebase + offsetfirst, whiledfs_elm_off_to_fsize()validates the result only afterwards. WithRT_USING_DFS_LARGE_FILE,off_tisint64_t; an input such asINT64_MAXplus a non-zero current position invokes signed-overflow undefined behavior before the conversion helper can reject it. Depending on optimization and architecture, this can produce a negative/wrapped position or bypass the intended range check.Please use a checked-add helper and return
-EOVERFLOWbefore performing the addition. For example:if ((offset > 0 && base > INT64_MAX - offset) || (offset < 0 && base < INT64_MIN - offset)) return -EOVERFLOW; result = base + offset;
The same boundary behavior should be covered for
SEEK_SET,SEEK_CUR,SEEK_END,ftruncate, read/write, and both DFS v1/v2 configurations where applicable. TestINT64_MAX,INT64_MIN, negative offsets, and values just beyond the FatFSFSIZE_tlimit.
一般 / General
-
dfs_elm_off_to_fsize()is duplicated in the v1 and v2 ELM implementations. A shared checked-conversion helper would reduce the chance that one implementation receives a future overflow fix while the other does not. -
This PR changes the public
off_tandstruct statABI behind a Kconfig switch. Please document the required full-image rebuild/configuration consistency and provide at least one 32-bit target test withFSIZE_tnarrower thanoff_t. -
The required PR description still contains the untouched template and does not state the tested BSP/configuration. Please fill it in before merge so reviewers can reproduce the large-file paths.
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
你的解决方案是什么 (what is your solution)
请提供验证的bsp和config (provide the config and bsp)
]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up