about summary refs log tree commit diff
path: root/src/usr.bin/calendar/calendar.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr.bin/calendar/calendar.c')
-rw-r--r--src/usr.bin/calendar/calendar.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/usr.bin/calendar/calendar.c b/src/usr.bin/calendar/calendar.c
index b5da818..b4605b0 100644
--- a/src/usr.bin/calendar/calendar.c
+++ b/src/usr.bin/calendar/calendar.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: calendar.c,v 1.29 2015/02/08 23:40:34 deraadt Exp $	*/
+/*	$OpenBSD: calendar.c,v 1.31 2015/04/18 18:28:37 deraadt Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1994
@@ -40,8 +40,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <limits.h>
 #include <time.h>
-#include <tzfile.h>
 #include <unistd.h>
 
 #include "pathnames.h"
@@ -68,6 +68,7 @@ int
 main(int argc, char *argv[])
 {
 	int ch;
+	const char *errstr;
 	char *caldir;
 
 	(void)setlocale(LC_ALL, "");
@@ -95,12 +96,16 @@ main(int argc, char *argv[])
 			break;
 
 		case 'A': /* days after current date */
-			f_dayAfter = atoi(optarg);
+			f_dayAfter = strtonum(optarg, 0, INT_MAX, &errstr);
+			if (errstr)
+				errx(1, "-A %s: %s", optarg, errstr);
 			f_SetdayAfter = 1;
 			break;
 
 		case 'B': /* days before current date */
-			f_dayBefore = atoi(optarg);
+			f_dayBefore = strtonum(optarg, 0, INT_MAX, &errstr);
+			if (errstr)
+				errx(1, "-B %s: %s", optarg, errstr);
 			break;
 
 		default: