Replace uses of localtime() with the re-entrant variant
LGTM flags localtime() as a "dangerous" function, which seems a bit over the top to me, but as we're flirting with threads, it certainly is not thread-safe.
This commit is contained in:
parent
d609a426f6
commit
9fe75561f9
|
@ -813,7 +813,7 @@ AC_CHECK_FUNCS([secure_getenv __secure_getenv])
|
|||
|
||||
AC_CHECK_FUNCS(
|
||||
[mkstemp getcwd basename dirname realpath setenv unsetenv regcomp lchown \
|
||||
utimes getline],
|
||||
utimes getline localtime_r ],
|
||||
[], [AC_MSG_ERROR([function required by rpm])])
|
||||
|
||||
AC_LIBOBJ(fnmatch)
|
||||
|
|
|
@ -96,10 +96,10 @@ static char * hexFormat(rpmtd td, char **emsg)
|
|||
static char * realDateFormat(rpmtd td, const char * strftimeFormat, char **emsg)
|
||||
{
|
||||
char * val = NULL;
|
||||
struct tm * tstruct;
|
||||
struct tm * tstruct, _tm;
|
||||
char buf[1024];
|
||||
time_t dateint = rpmtdGetNumber(td);
|
||||
tstruct = localtime(&dateint);
|
||||
tstruct = localtime_r(&dateint, &_tm);
|
||||
|
||||
buf[0] = '\0';
|
||||
if (tstruct)
|
||||
|
@ -361,7 +361,7 @@ static char * pgpsigFormat(rpmtd td, char **emsg)
|
|||
char *keyid = pgpHexStr(sigp->signid, sizeof(sigp->signid));
|
||||
unsigned int dateint = sigp->time;
|
||||
time_t date = dateint;
|
||||
struct tm * tms = localtime(&date);
|
||||
struct tm _tm, * tms = localtime_r(&date, &_tm);
|
||||
unsigned int key_algo = pgpDigParamsAlgo(sigp, PGPVAL_PUBKEYALGO);
|
||||
unsigned int hash_algo = pgpDigParamsAlgo(sigp, PGPVAL_HASHALGO);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ static void printFileInfo(const char * name,
|
|||
char ownerfield[8+1], groupfield[8+1];
|
||||
char timefield[100];
|
||||
time_t when = mtime; /* important if sizeof(int32_t) ! sizeof(time_t) */
|
||||
struct tm * tm;
|
||||
struct tm * tm, _tm;
|
||||
char * perms = rpmPermsString(mode);
|
||||
char *link = NULL;
|
||||
|
||||
|
@ -62,7 +62,7 @@ static void printFileInfo(const char * name,
|
|||
}
|
||||
|
||||
/* Convert file mtime to display format */
|
||||
tm = localtime(&when);
|
||||
tm = localtime_r(&when, &_tm);
|
||||
timefield[0] = '\0';
|
||||
if (tm != NULL)
|
||||
{ const char *fmt;
|
||||
|
|
Loading…
Reference in New Issue