Skip to content
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

[libc] [ctime] fix rt_timespec_to_tick fun internal data overflow #8198

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion components/libc/compilers/common/ctime.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,8 @@ RTM_EXPORT(clock_settime);
int rt_timespec_to_tick(const struct timespec *time)
{
int tick;
int nsecond, second;
int second;
long long nsecond;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

麻烦直接按照这个数据类型改吧

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用 long 的话 下面的计算方式 32 位下 还是会溢出的

struct timespec tp = {0};

RT_ASSERT(time != RT_NULL);
Expand Down