summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2016-07-13 21:32:01 +0000
committermillert <millert@openbsd.org>2016-07-13 21:32:01 +0000
commit45cf8591c43d281c4bfe683e7a4a2bb85687dac0 (patch)
tree14e6f07262012f170f2cca98e90914df02c6f797
parentThe "#address-cells" and "#size-cells" properties define the size (diff)
downloadwireguard-openbsd-45cf8591c43d281c4bfe683e7a4a2bb85687dac0.tar.xz
wireguard-openbsd-45cf8591c43d281c4bfe683e7a4a2bb85687dac0.zip
When matching a day in the month, make sure that the date is still
in the month we are interested in after calling mktime(3). This fixes things like Sunday+5 for months where there is not a 5th Sunday and the 31st day in months with less than 31 days. From Andy Bradford
-rw-r--r--usr.bin/calendar/day.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.bin/calendar/day.c b/usr.bin/calendar/day.c
index cea97096eb2..7e8da77e07b 100644
--- a/usr.bin/calendar/day.c
+++ b/usr.bin/calendar/day.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: day.c,v 1.32 2015/12/08 19:04:50 mmcc Exp $ */
+/* $OpenBSD: day.c,v 1.33 2016/07/13 21:32:01 millert Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
@@ -543,8 +543,9 @@ isnow(char *endp, int bodun)
tdiff = difftime(ttmp, f_time)/ SECSPERDAY;
if (tdiff <= offset + f_dayAfter ||
(bodun && tdiff == -1)) {
- if (tdiff >= 0 ||
- (bodun && tdiff == -1)) {
+ if ((tmtmp.tm_mon == month) &&
+ (tdiff >= 0 ||
+ (bodun && tdiff == -1))) {
if ((tmp = malloc(sizeof(struct match))) == NULL)
err(1, NULL);
tmp->when = ttmp;