]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hwclock: check errno after strto..()
authorKarel Zak <kzak@redhat.com>
Mon, 21 Jun 2021 13:00:40 +0000 (15:00 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 20 Jul 2021 09:33:27 +0000 (11:33 +0200)
Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/hwclock-rtc.c

index 7f1f0b6634f27d91254067f1ce70c967349865a7..07af9c83c356f8bfd8804b9ab40c81114e12f6fe 100644 (file)
@@ -425,10 +425,11 @@ int set_epoch_rtc(const struct hwclock_control *ctl)
        int rtc_fd;
        unsigned long epoch;
 
+       errno = 0;
        epoch = strtoul(ctl->epoch_option, NULL, 10);
 
        /* There were no RTC clocks before 1900. */
-       if (epoch < 1900 || epoch == ULONG_MAX) {
+       if (errno || epoch < 1900 || epoch == ULONG_MAX) {
                warnx(_("invalid epoch '%s'."), ctl->epoch_option);
                return 1;
        }