Module: kamailio
Branch: master
Commit: 0cc1e167b9e54bb4a652162445efe89b02939eed
URL:
https://github.com/kamailio/kamailio/commit/0cc1e167b9e54bb4a652162445efe89…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-07-06T08:50:00+02:00
db_redis: use safer localtime_r() function
---
Modified: src/modules/db_redis/redis_dbase.c
---
Diff:
https://github.com/kamailio/kamailio/commit/0cc1e167b9e54bb4a652162445efe89…
Patch:
https://github.com/kamailio/kamailio/commit/0cc1e167b9e54bb4a652162445efe89…
---
diff --git a/src/modules/db_redis/redis_dbase.c b/src/modules/db_redis/redis_dbase.c
index ea1a6aa43e..9c81385a39 100644
--- a/src/modules/db_redis/redis_dbase.c
+++ b/src/modules/db_redis/redis_dbase.c
@@ -1152,6 +1152,7 @@ static int db_redis_compare_column(db_key_t k, db_val_t *v, db_op_t
op, redisRep
double d_value;
str *tmpstr;
char tmp[32] = "";
+ struct tm _time;
int vtype = VAL_TYPE(v);
@@ -1283,7 +1284,8 @@ static int db_redis_compare_column(db_key_t k, db_val_t *v, db_op_t
op, redisRep
return -1;
case DB1_DATETIME:
// TODO: insert int value to db for faster comparison!
- strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S",
localtime(&(VAL_TIME(v))));
+ localtime_r(&(VAL_TIME(v)), &_time);
+ strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S", &_time);
LM_DBG("comparing DATETIME %s %s %s\n", reply->str, op, tmp);
if (!strcmp(op, OP_EQ)) {
return (strcmp(reply->str, tmp) == 0) ? 0 : -1;