+2021-12-01 Mark Wielaard <mark@klomp.org>
+
+ * debuginfod-client.c (timestamp): Use gmtime_r instead of gmtime.
+ (add_mhd_last_modified): Likewise.
+
2021-11-10 Érico N. Rolim <erico.erc@gmail.com>
* debuginfod.cxx: include "system.h" under 'extern "C"' block.
char datebuf[80];
char *now2 = NULL;
time_t now_t = time(NULL);
- struct tm *now = gmtime (&now_t);
- if (now)
+ struct tm now;
+ struct tm *nowp = gmtime_r (&now_t, &now);
+ if (nowp)
{
- (void) strftime (datebuf, sizeof (datebuf), "%c", now);
+ (void) strftime (datebuf, sizeof (datebuf), "%c", nowp);
now2 = datebuf;
}
static void
add_mhd_last_modified (struct MHD_Response *resp, time_t mtime)
{
- struct tm *now = gmtime (&mtime);
- if (now != NULL)
+ struct tm now;
+ struct tm *nowp = gmtime_r (&mtime, &now);
+ if (nowp != NULL)
{
char datebuf[80];
- size_t rc = strftime (datebuf, sizeof (datebuf), "%a, %d %b %Y %T GMT", now);
+ size_t rc = strftime (datebuf, sizeof (datebuf), "%a, %d %b %Y %T GMT",
+ nowp);
if (rc > 0 && rc < sizeof (datebuf))
(void) MHD_add_response_header (resp, "Last-Modified", datebuf);
}