diff options
| author | Thomas Huth <thuth@redhat.com> | 2026-05-18 18:34:08 +0200 |
|---|---|---|
| committer | Michael Tokarev <mjt@tls.msk.ru> | 2026-06-14 08:51:01 +0300 |
| commit | 991a955c0f65c56afb3e3f8733e0542a86836eed (patch) | |
| tree | 3439df3acb2a138c4f2802716910b5a61d3d0958 | |
| parent | c66b045e8e4c0bf2b96f1e642099dacc23d3b218 (diff) | |
| download | qemu-991a955c0f65c56afb3e3f8733e0542a86836eed.tar.gz qemu-991a955c0f65c56afb3e3f8733e0542a86836eed.zip | |
system/rtc: Fix a possible year-2038 integer overflow problem
rtc_realtime_clock_offset is initialized with:
rtc_realtime_clock_offset = qemu_clock_get_ms(QEMU_CLOCK_REALTIME) / 1000;
And QEMU_CLOCK_REALTIME might be based on gettimeofday() in certain
cases (see get_clock_realtime() in include/qemu/timer.h). So this
counter will exceed 32 bits in the year 2038, thus we should not
store this value in a normal integer variable. Change it to a time_t
to fix the problem.
And while we're at it, also adjust the nearby rtc_host_datetime_offset
variable to be on the safe side in the related code.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(cherry picked from commit ae84c738e40339cc0f22773dd4692de529d88739)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
| -rw-r--r-- | system/rtc.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/system/rtc.c b/system/rtc.c index 56951288c4..f7eca982b0 100644 --- a/system/rtc.c +++ b/system/rtc.c @@ -40,8 +40,8 @@ static enum { RTC_BASE_DATETIME, } rtc_base_type = RTC_BASE_UTC; static time_t rtc_ref_start_datetime; -static int rtc_realtime_clock_offset; /* used only with QEMU_CLOCK_REALTIME */ -static int rtc_host_datetime_offset = -1; /* valid & used only with +static time_t rtc_realtime_clock_offset; /* used only with QEMU_CLOCK_REALTIME */ +static time_t rtc_host_datetime_offset = -1; /* valid & used only with RTC_BASE_DATETIME */ QEMUClockType rtc_clock; /***********************************************************/ |
