Module: kamailio
Branch: master
Commit: 6007274938387359bb0a9b54528a5f3c87700356
URL:
https://github.com/kamailio/kamailio/commit/6007274938387359bb0a9b54528a5f3…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2020-05-12T14:49:47+02:00
jsonrpcs: use gmtime_r() for a safer multi-thread usage
---
Modified: src/modules/jsonrpcs/jsonrpcs_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/6007274938387359bb0a9b54528a5f3…
Patch:
https://github.com/kamailio/kamailio/commit/6007274938387359bb0a9b54528a5f3…
---
diff --git a/src/modules/jsonrpcs/jsonrpcs_mod.c b/src/modules/jsonrpcs/jsonrpcs_mod.c
index 5843d87a5f..b07ae802df 100644
--- a/src/modules/jsonrpcs/jsonrpcs_mod.c
+++ b/src/modules/jsonrpcs/jsonrpcs_mod.c
@@ -470,7 +470,7 @@ static srjson_t* jsonrpc_print_value(jsonrpc_ctx_t* ctx, char fmt,
va_list* ap)
srjson_t *nj = NULL;
char buf[JSONRPC_PRINT_VALUE_BUF_LEN];
time_t dt;
- struct tm* t;
+ struct tm t;
str *sp;
switch(fmt) {
@@ -488,9 +488,9 @@ static srjson_t* jsonrpc_print_value(jsonrpc_ctx_t* ctx, char fmt,
va_list* ap)
break;
case 't':
dt = va_arg(*ap, time_t);
- t = gmtime(&dt);
+ gmtime_r(&dt, &t);
if (strftime(buf, JSONRPC_PRINT_VALUE_BUF_LEN,
- "%Y%m%dT%H:%M:%S", t) == 0) {
+ "%Y%m%dT%H:%M:%S", &t) == 0) {
LM_ERR("Error while converting time\n");
return NULL;
}