Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Jun 2022 20:35:43 GMT
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 0a9541d9f344 - main - pw: reinitialize struct tm before every call to strptime
Message-ID:  <202206072035.257KZhsU022831@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by bapt:

URL: https://cgit.FreeBSD.org/src/commit/?id=0a9541d9f34498dfbb0913916652275076198964

commit 0a9541d9f34498dfbb0913916652275076198964
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2022-06-07 20:28:13 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2022-06-07 20:32:35 +0000

    pw: reinitialize struct tm before every call to strptime
    
    This prevents corrupted result due to leftover of previous failed
    call to strptime
---
 usr.sbin/pw/psdate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr.sbin/pw/psdate.c b/usr.sbin/pw/psdate.c
index 8c833b5c69c7..4baabb30427e 100644
--- a/usr.sbin/pw/psdate.c
+++ b/usr.sbin/pw/psdate.c
@@ -128,8 +128,8 @@ parse_datesub(char const * str, struct tm *t)
 
 	l = newlocale(LC_ALL_MASK, "C", NULL);
 
-	memset(&tm, 0, sizeof(tm));
 	for (i=0; valid_formats[i] != NULL; i++) {
+		memset(&tm, 0, sizeof(tm));
 		ret = strptime_l(str, valid_formats[i], &tm, l);
 		if (ret && *ret == '\0') {
 			t->tm_mday = tm.tm_mday;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202206072035.257KZhsU022831>