getdate would free the buffer pointed to by the result of its call to
strptime, then reference the same buffer later on -- leading to a
use-after-free. This commit fixes that.
Reported-by: Martin Coufal <mcoufal@redhat.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
struct tm tm;
struct __stat64_t64 st;
bool mday_ok = false;
+ bool found = false;
datemsk = getenv ("DATEMSK");
if (datemsk == NULL || *datemsk == '\0')
tp->tm_gmtoff = 0;
tp->tm_zone = NULL;
result = strptime (string, line, tp);
- if (result && *result == '\0')
+ if ((found = (result && *result == '\0')))
break;
}
while (!__feof_unlocked (fp));
/* Close template file. */
fclose (fp);
- if (result == NULL || *result != '\0')
+ if (!found)
return 7;
/* Get current time. */