]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hwclock: --set and --predict segmentation fault
authorJ William Piggott <elseifthen@gmx.com>
Tue, 18 Apr 2017 14:42:02 +0000 (10:42 -0400)
committerJ William Piggott <elseifthen@gmx.com>
Wed, 19 Apr 2017 02:39:05 +0000 (22:39 -0400)
Segmentation fault for --set or --predict when the
--date option is not included.

* sys-utils/hwclock.c: exit with an error message when
    the required --date option is missing.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
sys-utils/hwclock.c

index 0c587957d5f6305430a1e76079bf519483c0668f..bb3a9d8970ae15b36d57ae2b09dd29d0fdd77bab 100644 (file)
@@ -1505,6 +1505,10 @@ int main(int argc, char **argv)
        }
 
        if (ctl.set || ctl.predict) {
+               if (!ctl.date_opt){
+               warnx(_("--date is required for --set or --predict"));
+               hwclock_exit(&ctl, EX_USAGE);
+               }
                if (parse_date(&when, ctl.date_opt, NULL))
                        set_time = when.tv_sec;
                else {