RTEMS | score, libmisc, bsps: Fix time_t truncation to uint32_t (!1478)
Sharvin Neve (@Sharvin)
gitlab at rtems.org
Tue Sep 8 18:26:15 UTC 2026
Sharvin Neve created a merge request: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1478
Project:Branches: Sharvin/rtems:fix-time_t-truncation to rtems/rtos/rtems:main
Author: Sharvin Neve
Closes #5737.
Coverity reported multiple defects where time_t was assigned or converted
to uint32_t resulting in potential value truncation:
- In `cpukit/libmisc/cpuuse/cpuusagetop.c` (CID 1512539):
`print_time()` stored the result of `_Timestamp_Get_seconds()` in `uint32_t`,
causing truncation of 64-bit `time_t`. Decompose time using 64-bit seconds
with rollover boundary handling (`>=`) and clamp negative timestamps to 0.
- In `cpukit/score/src/schedulercbssetparameters.c`,
`cpukit/score/src/schedulercbscreateserver.c`, and
`cpukit/score/src/schedulercbsreleasejob.c` (CID 1512546):
`Thread_CPU_budget_control.available` is `uint32_t` while
`Scheduler_CBS_Parameters.budget` is `time_t`. Validate that the budget does
not exceed `UINT32_MAX` during server creation and parameter updates,
and explicitly cast upon job budget replenishment.
- In `bsps/shared/dev/getentropy/getentropy-cpucounter.c` (CID 1512551):
`bintime.sec` was shifted directly as signed `time_t`. Convert through
unsigned integer prior to 64-bit shift to prevent undefined behavior
on 32-bit `time_t` architectures.
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1478
You're receiving this email because of your account on gitlab.rtems.org. Unsubscribe from this thread: https://gitlab.rtems.org/-/sent_notifications/5-egx25673xo3ewssg5bk5hsrp4-1d/unsubscribe | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | Help: https://gitlab.rtems.org/help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20260908/a4800404/attachment.htm>
More information about the bugs
mailing list