-
Notifications
You must be signed in to change notification settings - Fork 5.2k
fix(klibc\kstdio): vsnprinf size_t can not exceed INT32_MAX, don't u… #10205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses an issue with rt_vsprintf by ensuring that the size parameter passed to rt_vsnprintf does not exceed the maximum allowed value. The change replaces the previously used (rt_size_t)-1 with INT32_MAX to enforce the correct upper limit.
- Changes rt_vsprintf to call rt_vsnprintf with INT32_MAX
- Aligns the size parameter with the constraints of vsnprintf on target platforms
Comments suppressed due to low confidence (1)
src/klibc/kstdio.c:54
- Replacing (rt_size_t)-1 with INT32_MAX enforces the correct maximum size for rt_vsnprintf. Please ensure that INT32_MAX is defined and available on all target platforms.
return rt_vsnprintf(buf, INT32_MAX, format, arg_ptr);
这个问题完全可以复现的,编译器直接就会警告。所有相关的rt_vsprintf数都会执行失败返回-1。感觉应该尽快修复 |
可否具体讲讲复现方法吗?这边ci检测看起来没有报warning。 |
或者也可以把报错截图发出来 |
需要使能使用 libc的 vsnprintf |
…se (rt_size_t -1)
拉取/合并请求描述:(PR description)
[
开启RT_KLIBC_USING_LIBC_VSNPRINTF后,rt_vsprintf 执行异常。排查原因为 vsnprinf 的 size 参数不能超过 INT32 最大值。
编译器
arm-none-eabi-gcc v10.3.1
mcu
stm32h7xx
]
当前拉取/合并请求的状态 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