calendar(1): don't segfault in invalid input
When the user supplies an invalid number of days provide a useful error message instead of segfaulting. PR: bin/186697 Reported by: kaltheat <kaltheat@gmail.com> Submitted by: oliver <oliver@beefrankly.org> (older version)
This commit is contained in:
parent
7e1a619d03
commit
81479c5c55
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user