[PATCH 1/8] cmd: date: improve day of month verification

Alexander Feilke Alexander.Feilke at ew.tq-group.com
Fri May 8 10:21:25 CEST 2026


From: Markus Niebel <Markus.Niebel at ew.tq-group.com>

Use rtc_month_days instead of oversimplified local logic.

Signed-off-by: Markus Niebel <Markus.Niebel at ew.tq-group.com>
---
 cmd/date.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cmd/date.c b/cmd/date.c
index d047872289c..158449ef0fc 100644
--- a/cmd/date.c
+++ b/cmd/date.c
@@ -167,12 +167,12 @@ 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)) {
+		    val > rtc_month_days(tmp->tm_mon - 1, tmp->tm_year)) {
 			break;
 		}
 		tmp->tm_mday = val;
-- 
2.34.1



More information about the U-Boot mailing list