diff --git a/usr.bin/calendar/calendar.c b/usr.bin/calendar/calendar.c index 2a107c26afd5..84d188071ea9 100644 --- a/usr.bin/calendar/calendar.c +++ b/usr.bin/calendar/calendar.c @@ -96,10 +96,14 @@ main(int argc, char *argv[]) case 'A': /* days after current date */ f_dayAfter = atoi(optarg); + if (f_dayAfter < 0) + errx(1, "number of days must be positive"); break; case 'B': /* days before current date */ f_dayBefore = atoi(optarg); + if (f_dayBefore < 0) + errx(1, "number of days must be positive"); break; case 'D': /* debug output of sun and moon info */