Skip to content

Commit

Permalink
libs/srdb1: use thread safe localtime_r()
Browse files Browse the repository at this point in the history
(cherry picked from commit c01633d)
  • Loading branch information
miconda committed May 6, 2020
1 parent f3dbeda commit ac3fe06
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/srdb1/db_ut.c
Expand Up @@ -350,7 +350,7 @@ int db_str2time(const char* _s, time_t* _v)
*/
int db_time2str_ex(time_t _v, char* _s, int* _l, int _qmode)
{
struct tm* t;
struct tm t;
int l;

if ((!_s) || (!_l) || (*_l < 2)) {
Expand All @@ -361,8 +361,8 @@ int db_time2str_ex(time_t _v, char* _s, int* _l, int _qmode)
if(_qmode) *_s++ = '\'';

/* Convert time_t structure to format accepted by the database */
t = localtime(&_v);
l = strftime(_s, *_l -1, "%Y-%m-%d %H:%M:%S", t);
localtime_r(&_v, &t);
l = strftime(_s, *_l -1, "%Y-%m-%d %H:%M:%S", &t);

if (l == 0) {
LM_ERR("Error during time conversion\n");
Expand Down

0 comments on commit ac3fe06

Please sign in to comment.