From 66bea965dc62d545eb12de8c4384665338f614e2 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 8 Feb 2020 13:34:57 +0100 Subject: [PATCH] xbps_register_pkg: switch to localtime_r(3). lgtm suggested that localtime() is not reentrant, so that we now use localtime_r() instead. lgtm reports 0 alerts after this change, yay. --- lib/package_register.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/package_register.c b/lib/package_register.c index e482493e..6dee332c 100644 --- a/lib/package_register.c +++ b/lib/package_register.c @@ -38,6 +38,7 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd) xbps_dictionary_t pkgd; char outstr[64]; time_t t; + struct tm tm; struct tm *tmp; const char *pkgver; char *pkgname = NULL, *buf, *sha256; @@ -76,8 +77,8 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd) * Set the "install-date" object to know the pkg installation date. */ t = time(NULL); - if ((tmp = localtime(&t)) == NULL) { - xbps_dbg_printf(xhp, "%s: localtime failed: %s\n", + if ((tmp = localtime_r(&t, &tm)) == NULL) { + xbps_dbg_printf(xhp, "%s: localtime_r failed: %s\n", pkgver, strerror(errno)); rv = EINVAL; goto out;