summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/date.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/cmd/date.c b/cmd/date.c
index f7ecdac7dd3..67cfaed0d48 100644
--- a/cmd/date.c
+++ b/cmd/date.c
@@ -167,12 +167,13 @@ static int mk_date(const char *datestr, struct rtc_time *tmp)
/* fall thru */
case 12: /* MMDDhhmmCCYY */
if (cnvrt2 (datestr+0, &val) ||
- val > 12) {
+ val > 12 || val < 1) {
break;
}
tmp->tm_mon = val;
- if (cnvrt2 (datestr+2, &val) ||
- val > ((tmp->tm_mon==2) ? 29 : 31)) {
+ if (cnvrt2(datestr + 2, &val) ||
+ val < 1 ||
+ val > rtc_month_days(tmp->tm_mon - 1, tmp->tm_year)) {
break;
}
tmp->tm_mday = val;