summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authoreadler <eadler@FreeBSD.org>2014-02-17 03:24:00 +0000
committereadler <eadler@FreeBSD.org>2014-02-17 03:24:00 +0000
commit660e125cbcccce5c33a9ede039c30065cfd207d4 (patch)
treeaecad59b2b1628f7ff62cf0ebdec09206f83e503 /usr.bin
parent56a90dfc6e22e3528e3e407748cd2d2484aafb4b (diff)
downloadFreeBSD-src-660e125cbcccce5c33a9ede039c30065cfd207d4.zip
FreeBSD-src-660e125cbcccce5c33a9ede039c30065cfd207d4.tar.gz
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)
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/calendar/calendar.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/usr.bin/calendar/calendar.c b/usr.bin/calendar/calendar.c
index 2a107c2..84d1880 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 */
OpenPOWER on IntegriCloud