]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hwclock: make sure struct tm is initialized
authorKarel Zak <kzak@redhat.com>
Tue, 11 Apr 2023 10:24:56 +0000 (12:24 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 11 Apr 2023 10:24:56 +0000 (12:24 +0200)
Addresses: https://github.com/util-linux/util-linux/pull/2123
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/hwclock-rtc.c
sys-utils/hwclock.c

index c8ac627b1eb486b48a294c4a4f22f4410b487cc4..9a9939a1a6a8b6748748c9a45906bf9d19eade8f 100644 (file)
@@ -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 };
 
index 0dfe7f0841b7a6c8bd0b6812de6f295e16a18408..2a1844309bbcda07062d3182675fa40a6057e6a1 100644 (file)
@@ -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;