From 45cf8591c43d281c4bfe683e7a4a2bb85687dac0 Mon Sep 17 00:00:00 2001 From: millert Date: Wed, 13 Jul 2016 21:32:01 +0000 Subject: [PATCH] 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 --- usr.bin/calendar/day.c | 7 ++++--- 1 file 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; -- 2.20.1