From 0bc13e0175e645d625d9bcb81be7d55d6ffef189 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 11 Apr 2023 12:24:56 +0200 Subject: [PATCH] hwclock: make sure struct tm is initialized Addresses: https://github.com/util-linux/util-linux/pull/2123 Signed-off-by: Karel Zak --- sys-utils/hwclock-rtc.c | 4 ++-- sys-utils/hwclock.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sys-utils/hwclock-rtc.c b/sys-utils/hwclock-rtc.c index c8ac627b1e..9a9939a1a6 100644 --- a/sys-utils/hwclock-rtc.c +++ b/sys-utils/hwclock-rtc.c @@ -155,9 +155,9 @@ static int do_rtc_read_ioctl(int rtc_fd, struct tm *tm) static int busywait_for_rtc_clock_tick(const struct hwclock_control *ctl, const int rtc_fd) { - struct tm start_time; + struct tm start_time = { 0 }; /* The time when we were called (and started waiting) */ - struct tm nowtime; + struct tm nowtime = { 0 }; int rc; struct timeval begin = { 0 }, now = { 0 }; diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c index 0dfe7f0841..2a1844309b 100644 --- a/sys-utils/hwclock.c +++ b/sys-utils/hwclock.c @@ -381,7 +381,7 @@ static int read_hardware_clock(const struct hwclock_control *ctl, int *valid_p, time_t *systime_p) { - struct tm tm; + struct tm tm = { 0 }; int err; err = ur->read_hardware_clock(ctl, &tm); @@ -404,7 +404,7 @@ read_hardware_clock(const struct hwclock_control *ctl, static void set_hardware_clock(const struct hwclock_control *ctl, const time_t newtime) { - struct tm new_broken_time; + struct tm new_broken_time = { 0 }; /* * Time to which we will set Hardware Clock, in broken down format, * in the time zone of caller's choice @@ -705,7 +705,7 @@ static int set_system_clock(const struct hwclock_control *ctl, const struct timeval newtime) { - struct tm broken; + struct tm broken = { 0 }; int minuteswest; int rc = 0; -- 2.47.2