Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <V4NZ1ISdssdPCgA7HUwkxx5G-M0Raou-jMQgLj4B5eWybqPJfaoQtrSqfSKrIPZA7d4HzcJT1XLiUYks5ywX99Wco_kT__HGiy0af1hPIdo=@proton.me>
Date: Fri, 27 Nov 2026 14:39:49 +0000
From: AyadiCH <ayadich@...ton.me>
To: musl@...ts.openwall.com
Subject: Re: getdate() returns invalid date

this should fix it, it get out from Bruno's test and should
be as specified in the posix, thanks a lot Burno!

Ayadi

----
>From 8e1a6138dd77718d38087e06a027b49414e1edd8 Mon Sep 17 00:00:00 2001
From: Ayadi <ayadich@...ton.me>
Date: Fri, 27 Nov 2026 15:33:11 +0100
Subject: [PATCH] fixing getdate

---
 src/time/getdate.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/time/getdate.c b/src/time/getdate.c
index 420cd8e4..649f3c96 100644
--- a/src/time/getdate.c
+++ b/src/time/getdate.c
@@ -14,7 +14,9 @@ struct tm *getdate(const char *s)
 	FILE *f = 0;
 	char fmt[100], *p;
 	int cs;
-
+	time_t rtm;
+	int ptm_hour, ptm_min, ptm_sec;
+	
 	pthread_setcancelstate(PTHREAD_CANCEL_DEFERRED, &cs);
 
 	if (!datemsk) {
@@ -29,9 +31,25 @@ struct tm *getdate(const char *s)
 		goto out;
 	}
 
+	time(&rtm);
 	while (fgets(fmt, sizeof fmt, f)) {
-		p = strptime(s, fmt, &tmbuf);
+		localtime_r(&rtm,&tmbuf);
+		ptm_hour=tmbuf.tm_hour;ptm_min=tmbuf.tm_min;ptm_sec=tmbuf.tm_sec;
+		tmbuf.tm_min = tmbuf.tm_sec =tmbuf.tm_hour= -1;
+		p = strptime(s, fmt, &tmbuf);	
+		
 		if (p && !*p) {
+			if(tmbuf.tm_hour == -1){
+				tmbuf.tm_hour = ptm_hour;
+				tmbuf.tm_min  = ptm_min;
+				tmbuf.tm_sec  = ptm_sec;
+			}
+			if(tmbuf.tm_min == -1){
+				tmbuf.tm_min = 0;
+			}
+			if(tmbuf.tm_sec == -1){
+				tmbuf.tm_sec = 0;
+			}
 			ret = &tmbuf;
 			goto out;
 		}
-- 
2.56.1

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.