From 0a9541d9f34498dfbb0913916652275076198964 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Tue, 7 Jun 2022 22:28:13 +0200 Subject: [PATCH] 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;