Browse code

db_redis: use safer localtime_r() function

Daniel-Constantin Mierla authored on 05/07/2020 18:50:00
Showing 1 changed files
... ...
@@ -1152,6 +1152,7 @@ static int db_redis_compare_column(db_key_t k, db_val_t *v, db_op_t op, redisRep
1152 1152
     double d_value;
1153 1153
     str *tmpstr;
1154 1154
     char tmp[32] = "";
1155
+    struct tm _time;
1155 1156
 
1156 1157
     int vtype = VAL_TYPE(v);
1157 1158
 
... ...
@@ -1283,7 +1284,8 @@ static int db_redis_compare_column(db_key_t k, db_val_t *v, db_op_t op, redisRep
1283 1284
             return -1;
1284 1285
         case DB1_DATETIME:
1285 1286
             // TODO: insert int value to db for faster comparison!
1286
-            strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S", localtime(&(VAL_TIME(v))));
1287
+            localtime_r(&(VAL_TIME(v)), &_time);
1288
+            strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S", &_time);
1287 1289
             LM_DBG("comparing DATETIME %s %s %s\n", reply->str, op, tmp);
1288 1290
             if (!strcmp(op, OP_EQ)) {
1289 1291
                 return (strcmp(reply->str, tmp) == 0) ? 0 : -1;