git: 0a9541d9f344 - main - pw: reinitialize struct tm before every call to strptime

From: Baptiste Daroussin <bapt_at_FreeBSD.org>
Date: Tue, 07 Jun 2022 20:35:43 UTC
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;