1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
diff -up calendar-1.37-20190827cvs/calendar.c.orig calendar-1.37-20190827cvs/calendar.c
--- calendar-1.37-20190827cvs/calendar.c.orig 2019-02-01 11:22:53.000000000 -0500
+++ calendar-1.37-20190827cvs/calendar.c 2019-08-27 15:50:25.766758389 -0400
@@ -35,7 +35,6 @@
#include <err.h>
#include <errno.h>
#include <locale.h>
-#include <login_cap.h>
#include <pwd.h>
#include <signal.h>
#include <stdio.h>
@@ -98,16 +97,20 @@ main(int argc, char *argv[])
break;
case 'A': /* days after current date */
- f_dayAfter = strtonum(optarg, 0, INT_MAX, &errstr);
- if (errstr)
- errx(1, "-A %s: %s", optarg, errstr);
+ f_dayAfter = strtoll(optarg, NULL, 10);
+ if (errno == ERANGE && (f_dayAfter == LLONG_MIN || f_dayBefore == LLONG_MAX))
+ errx(1, "-A %s: %s", optarg, strerror(errno));
+ else if (f_dayAfter < 0 || f_dayAfter > INT_MAX)
+ errx(1, "-A %s: %s out of range", optarg, strerror(errno));
f_Setday = 1;
break;
case 'B': /* days before current date */
- f_dayBefore = strtonum(optarg, 0, INT_MAX, &errstr);
- if (errstr)
- errx(1, "-B %s: %s", optarg, errstr);
+ f_dayBefore = strtoll(optarg, NULL, 10);
+ if (errno == ERANGE && (f_dayBefore == LLONG_MIN || f_dayBefore == LLONG_MAX))
+ errx(1, "-B %s: %s", optarg, strerror(errno));
+ else if (f_dayBefore < 0 || f_dayBefore > INT_MAX)
+ errx(1, "-B %s: %s out of range", optarg, strerror(errno));
if (f_dayBefore != 0)
f_Setday = 1;
break;
@@ -125,15 +128,6 @@ main(int argc, char *argv[])
if (argc)
usage();
- if (doall) {
- if (pledge("stdio rpath tmppath fattr getpw id proc exec", NULL)
- == -1)
- err(1, "pledge");
- } else {
- if (pledge("stdio rpath proc exec", NULL) == -1)
- err(1, "pledge");
- }
-
/* use current time */
if (f_time <= 0)
(void)time(&f_time);
@@ -192,10 +186,6 @@ main(int argc, char *argv[])
case 0: /* child */
(void)setpgid(getpid(), getpid());
(void)setlocale(LC_ALL, "");
- if (setusercontext(NULL, pw, pw->pw_uid,
- LOGIN_SETALL ^ LOGIN_SETLOGIN))
- err(1, "unable to set user context (uid %u)",
- pw->pw_uid);
if (acstat) {
if (chdir(pw->pw_dir) ||
stat(calendarFile, &sbuf) != 0 ||
diff -up calendar-1.37-20190827cvs/calendar.h.orig calendar-1.37-20190827cvs/calendar.h
--- calendar-1.37-20190827cvs/calendar.h.orig 2019-02-01 11:22:53.000000000 -0500
+++ calendar-1.37-20190827cvs/calendar.h 2019-08-27 15:49:16.082984894 -0400
@@ -29,6 +29,7 @@
* SUCH DAMAGE.
*/
+#include <sys/types.h>
extern struct passwd *pw;
extern int doall;
@@ -116,7 +117,7 @@ extern int f_Setday; /* calendar invoked
/* calendars */
extern enum calendars { GREGORIAN = 0, JULIAN, LUNAR } calendar;
-extern u_long julian;
+extern unsigned long julian;
#define NUMEV 3 /* Total number of such special events */
extern struct specialev spev[NUMEV];
diff -up calendar-1.37-20190827cvs/day.c.orig calendar-1.37-20190827cvs/day.c
--- calendar-1.37-20190827cvs/day.c.orig 2019-02-01 11:22:53.000000000 -0500
+++ calendar-1.37-20190827cvs/day.c 2019-08-27 15:49:31.774933887 -0400
@@ -160,7 +160,7 @@ settime(time_t *now)
tp->tm_isdst = 0;
tp->tm_hour = 12;
*now = mktime(tp);
- if (isleap(tp->tm_year + 1900))
+ if (__isleap(tp->tm_year + 1900))
cumdays = daytab[1];
else
cumdays = daytab[0];
@@ -288,8 +288,10 @@ isnow(char *endp, int bodun)
return (NULL);
/* adjust bodun rate */
- if (bodun && !bodun_always)
- bodun = !arc4random_uniform(3);
+ if (bodun && !bodun_always) {
+ srandom(3);
+ bodun = random();
+ }
/* Easter or Easter depending days */
if (flags & F_SPECIAL)
@@ -440,7 +442,7 @@ isnow(char *endp, int bodun)
}
v2 = day - tp->tm_yday;
if ((v2 > v1) || (v2 < 0)) {
- if ((v2 += isleap(tp->tm_year + 1900) ? 366 : 365)
+ if ((v2 += __isleap(tp->tm_year + 1900) ? 366 : 365)
<= v1)
tmtmp.tm_year++;
else if(!bodun || (day - tp->tm_yday) != -1)
@@ -670,7 +672,7 @@ variable_weekday(int *day, int month, in
int *cumdays;
int day1;
- if (isleap(year))
+ if (__isleap(year))
cumdays = daytab[1];
else
cumdays = daytab[0];
diff -up calendar-1.37-20190827cvs/io.c.orig calendar-1.37-20190827cvs/io.c
--- calendar-1.37-20190827cvs/io.c.orig 2019-01-29 17:28:30.000000000 -0500
+++ calendar-1.37-20190827cvs/io.c 2019-08-27 15:50:56.117659733 -0400
@@ -67,7 +67,7 @@ void
cal(void)
{
int ch, l, i, bodun = 0, bodun_maybe = 0, var, printing;
- struct event *events, *cur_evt, *ev1, *tmp;
+ struct event *events = NULL, *cur_evt = NULL, *ev1 = NULL, *tmp = NULL;
char buf[2048 + 1], *prefix = NULL, *p;
struct match *m;
FILE *fp;
@@ -282,8 +282,8 @@ getfield(char *p, char **endp, int *flag
switch (*start) {
case '-':
case '+':
- var = strtonum(start + 1, 0, 365, &errstr);
- if (errstr)
+ var = strtoll(start + 1, NULL, 10);
+ if ((errno == ERANGE && (var == LLONG_MIN || var == LLONG_MAX)) || (var < 0 || var > 365))
return (0); /* Someone is just being silly */
if (*start == '-')
var = -var;
diff -up calendar-1.37-20190827cvs/ostern.c.orig calendar-1.37-20190827cvs/ostern.c
--- calendar-1.37-20190827cvs/ostern.c.orig 2019-01-17 01:15:44.000000000 -0500
+++ calendar-1.37-20190827cvs/ostern.c 2019-08-27 15:49:16.082984894 -0400
@@ -58,7 +58,7 @@ easter(int year) /* 0 ... abcd, NOT sinc
e_p = e_p + 1;
e_q = 31 + 28 + e_p;
- if (isleap(year))
+ if (__isleap(year))
e_q++;
if (e_n == 4)
diff -up calendar-1.37-20190827cvs/paskha.c.orig calendar-1.37-20190827cvs/paskha.c
--- calendar-1.37-20190827cvs/paskha.c.orig 2015-03-14 20:41:28.000000000 -0400
+++ calendar-1.37-20190827cvs/paskha.c 2019-08-27 15:49:16.082984894 -0400
@@ -27,6 +27,7 @@
*/
#include <stdio.h>
+#include <time.h>
#include "calendar.h"
@@ -47,7 +48,7 @@ paskha(int R) /*year*/
d = (19*a + x) % 30;
e = (2*b + 4*c + 6*d + y) % 7;
cumdays = 31 + 28;
- if (isleap(R))
+ if (__isleap(R))
cumdays++;
return ((cumdays + 22) + (d + e) + 13);
}
diff -up calendar-1.37-20190827cvs/pathnames.h.orig calendar-1.37-20190827cvs/pathnames.h
--- calendar-1.37-20190827cvs/pathnames.h.orig 2014-07-30 12:46:17.000000000 -0400
+++ calendar-1.37-20190827cvs/pathnames.h 2019-08-27 15:49:16.082984894 -0400
@@ -33,7 +33,7 @@
#include <paths.h>
-#define _PATH_CPP "/usr/libexec/tradcpp"
+#define _PATH_CPP "/usr/bin/cpp"
/* XXX -- fix when cpp parses arguments rationally */
#define _PATH_INCLUDE "-I/usr/share/calendar"
diff -up calendar-1.37-20190827cvs/pesach.c.orig calendar-1.37-20190827cvs/pesach.c
--- calendar-1.37-20190827cvs/pesach.c.orig 2015-03-14 20:41:28.000000000 -0400
+++ calendar-1.37-20190827cvs/pesach.c 2019-08-27 15:49:16.083984890 -0400
@@ -18,6 +18,7 @@
*/
#include <stdio.h>
+#include <time.h>
#include "calendar.h"
@@ -61,5 +62,5 @@ pesach(int R)
if (R > 1582)
cumdays += R / 100 - R /400 - 2;
- return (31 + 28 + cumdays + (isleap(R)? 1 : 0));
+ return (31 + 28 + cumdays + (__isleap(R)? 1 : 0));
}
|