]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hwclock: use reentrant time conversion functions
authorJ William Piggott <elseifthen@gmx.com>
Sun, 22 Oct 2017 00:40:58 +0000 (20:40 -0400)
committerJ William Piggott <elseifthen@gmx.com>
Fri, 17 Nov 2017 00:43:16 +0000 (19:43 -0500)
Signed-off-by: J William Piggott <elseifthen@gmx.com>
sys-utils/hwclock.c

index c93a5fd65f7997aebbcf143b710f0da1b6d52157..8ff33474e05231de138a157bf07e35d08bf3ff58 100644 (file)
@@ -375,9 +375,9 @@ set_hardware_clock(const struct hwclock_control *ctl, const time_t newtime)
         */
 
        if (ctl->universal)
-               new_broken_time = *gmtime(&newtime);
+               gmtime_r(&newtime, &new_broken_time);
        else
-               new_broken_time = *localtime(&newtime);
+               localtime_r(&newtime, &new_broken_time);
 
        if (ctl->debug)
                printf(_("Setting Hardware Clock to %.2d:%.2d:%.2d "
@@ -600,13 +600,13 @@ static int
 set_system_clock(const struct hwclock_control *ctl,
                 const struct timeval newtime)
 {
-       struct tm *broken;
+       struct tm broken;
        int minuteswest;
        int rc = 0;
        const struct timezone tz_utc = { 0 };
 
-       broken = localtime(&newtime.tv_sec);
-       minuteswest = -get_gmtoff(broken) / 60;
+       localtime_r(&newtime.tv_sec, &broken);
+       minuteswest = -get_gmtoff(&broken) / 60;
 
        if (ctl->debug) {
                if (ctl->hctosys && !ctl->universal)