Module: kamailio
Branch: master
Commit: f9ae11746fb820bb24057f4b3509bd59b6d3e936
URL:
https://github.com/kamailio/kamailio/commit/f9ae11746fb820bb24057f4b3509bd5…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2020-05-12T14:30:26+02:00
db_redis: use localtime_r() for a safer multi-thread usage
---
Modified: src/modules/db_redis/redis_dbase.c
---
Diff:
https://github.com/kamailio/kamailio/commit/f9ae11746fb820bb24057f4b3509bd5…
Patch:
https://github.com/kamailio/kamailio/commit/f9ae11746fb820bb24057f4b3509bd5…
---
diff --git a/src/modules/db_redis/redis_dbase.c b/src/modules/db_redis/redis_dbase.c
index f3b7c1f019..ea1a6aa43e 100644
--- a/src/modules/db_redis/redis_dbase.c
+++ b/src/modules/db_redis/redis_dbase.c
@@ -81,6 +81,7 @@ static int db_redis_val2str(const db_val_t *v, str *_str) {
const char *s;
const str *tmpstr;
int vtype = VAL_TYPE(v);
+ struct tm _time;
_str->s = NULL;
_str->len = 32; // default for numbers
@@ -144,7 +145,8 @@ static int db_redis_val2str(const db_val_t *v, str *_str) {
LM_DBG("converting datetime value %ld to str\n", VAL_TIME(v));
_str->s = (char*)pkg_malloc(_str->len);
if (!_str->s) goto memerr;
- strftime(_str->s, _str->len, "%Y-%m-%d %H:%M:%S",
localtime(&(VAL_TIME(v))));
+ localtime_r(&(VAL_TIME(v)), &_time);
+ strftime(_str->s, _str->len, "%Y-%m-%d %H:%M:%S",
&_time);
_str->len = strlen(_str->s);
break;
case DB1_DOUBLE: