From c1bc9f8557100d0712a4284398d6eef6439fb856 Mon Sep 17 00:00:00 2001 From: Johannes Schlatow Date: Wed, 6 Dec 2023 15:05:40 +0100 Subject: [PATCH] libc: use `timegm` instead of `mktime` By using `mktime()`, which assumes local time, we render the `TZ` environment variable ineffective. Instead, `timegm()` should be used to set the real-time clock to UTC. genodelabs/genode#5074 --- repos/libports/src/lib/libc/internal/rtc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repos/libports/src/lib/libc/internal/rtc.h b/repos/libports/src/lib/libc/internal/rtc.h index cb10fd1335..0dcdd5539d 100644 --- a/repos/libports/src/lib/libc/internal/rtc.h +++ b/repos/libports/src/lib/libc/internal/rtc.h @@ -55,7 +55,7 @@ struct Libc::Rtc : Vfs::Watch_response_handler struct tm tm { }; if (strptime(buf, "%Y-%m-%d %H:%M:%S", &tm) || strptime(buf, "%Y-%m-%d %H:%M", &tm)) { - _rtc_value = mktime(&tm); + _rtc_value = timegm(&tm); if (_rtc_value == (time_t)-1) _rtc_value = 0; }