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.
This commit is contained in:
parent
7d934c9290
commit
66bea965dc
@ -38,6 +38,7 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd)
|
|||||||
xbps_dictionary_t pkgd;
|
xbps_dictionary_t pkgd;
|
||||||
char outstr[64];
|
char outstr[64];
|
||||||
time_t t;
|
time_t t;
|
||||||
|
struct tm tm;
|
||||||
struct tm *tmp;
|
struct tm *tmp;
|
||||||
const char *pkgver;
|
const char *pkgver;
|
||||||
char *pkgname = NULL, *buf, *sha256;
|
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.
|
* Set the "install-date" object to know the pkg installation date.
|
||||||
*/
|
*/
|
||||||
t = time(NULL);
|
t = time(NULL);
|
||||||
if ((tmp = localtime(&t)) == NULL) {
|
if ((tmp = localtime_r(&t, &tm)) == NULL) {
|
||||||
xbps_dbg_printf(xhp, "%s: localtime failed: %s\n",
|
xbps_dbg_printf(xhp, "%s: localtime_r failed: %s\n",
|
||||||
pkgver, strerror(errno));
|
pkgver, strerror(errno));
|
||||||
rv = EINVAL;
|
rv = EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
|
Loading…
Reference in New Issue
Block a user