=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/calendar/day.c,v retrieving revision 1.35 retrieving revision 1.37 diff -u -r1.35 -r1.37 --- src/usr.bin/calendar/day.c 2019/01/29 20:08:56 1.35 +++ src/usr.bin/calendar/day.c 2019/08/12 20:03:28 1.37 @@ -1,4 +1,4 @@ -/* $OpenBSD: day.c,v 1.35 2019/01/29 20:08:56 millert Exp $ */ +/* $OpenBSD: day.c,v 1.37 2019/08/12 20:03:28 millert Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -166,7 +166,7 @@ cumdays = daytab[0]; /* Friday displays Monday's events */ offset = tp->tm_wday == 5 ? 3 : 1; - if (f_dayAfter || f_dayBefore) + if (f_Setday) offset = 0; /* Except not when range is set explicitly */ header[5].iov_base = dayname; @@ -323,10 +323,12 @@ if (month == -1) { month = tp->tm_mon + 1; interval = MONTHLY; - } else if (calendar) - adjust_calendar(&day, &month); - if ((month > 12) || (month < 1)) - return (NULL); + } else { + if ((month > 12) || (month < 1)) + return (NULL); + if (calendar) + adjust_calendar(&day, &month); + } } /* 2. {Monthname} XYZ ... */ @@ -371,6 +373,8 @@ else { /* F_ISDAY set, v2 > 12, or no way to tell */ month = v1; + if ((month > 12) || (month < 1)) + return (NULL); /* if no recognizable day, assume the first */ day = v2 ? v2 : 1; if ((flags & F_ISDAY)) {