RTEMS | kern_tc.c: Uses int32_t not time_t (time overflow) (#5204)
Joel Sherrill (@joel)
gitlab at rtems.org
Thu Feb 6 15:15:00 UTC 2025
Joel Sherrill created an issue: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5204
Assignee: Joel Sherrill
## Summary
This was spotted by Coverity Scan and manifests as CID 1512549 and 1512552.
```
1807 time_second = th->th_microtime.tv_sec;
CID 1512552: (#1 of 1): Use of 32-bit time_t (Y2K38_SAFETY)
1. store_truncates_time_t: A time_t value is stored in an integer with too few bits to accommodate it. The expression th->th_offset.sec is cast to int32_t.
1808 time_uptime = th->th_offset.sec;
```
_time_uptime_ is declared in kern_tc.c as:
```
#ifndef __rtems__
volatile time_t time_second = 1;
volatile time_t time_uptime = 1;
#else /* __rtems__ */
volatile time_t time_second = TOD_SECONDS_1970_THROUGH_1988;
volatile int32_t time_uptime = 1;
#endif /* __rtems__ */
```
It needs to be changed to int32_t to avoid overflow in 2038.
### Pre-set options
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5204
You're receiving this email because of your account on gitlab.rtems.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20250206/13eea733/attachment.htm>
More information about the bugs
mailing list