Module: kamailio
Branch: master
Commit: 14645b550cf9500e6a6e4a7d2ed8749e9aa174dc
URL:
https://github.com/kamailio/kamailio/commit/14645b550cf9500e6a6e4a7d2ed8749…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-05-06T17:03:45+02:00
pv: use localtime_r() for a safer multi-thread usage
---
Modified: src/modules/pv/pv_trans.c
---
Diff:
https://github.com/kamailio/kamailio/commit/14645b550cf9500e6a6e4a7d2ed8749…
Patch:
https://github.com/kamailio/kamailio/commit/14645b550cf9500e6a6e4a7d2ed8749…
---
diff --git a/src/modules/pv/pv_trans.c b/src/modules/pv/pv_trans.c
index 826fa9c2ef..d07e55e719 100644
--- a/src/modules/pv/pv_trans.c
+++ b/src/modules/pv/pv_trans.c
@@ -195,6 +195,7 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
pv_value_t v, w;
time_t t;
uint32_t sz1, sz2;
+ struct tm tmv;
if(val==NULL || val->flags&PV_VAL_NULL)
return -1;
@@ -1045,8 +1046,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int
subtype,
memcpy(s, st.s, st.len);
s[st.len] = '\0';
t = val->ri;
- val->rs.len = strftime(_tr_buffer, TR_BUFFER_SIZE-1, s,
- localtime(&t));
+ localtime_r(&t, &tmv);
+ val->rs.len = strftime(_tr_buffer, TR_BUFFER_SIZE-1, s, &tmv);
pkg_free(s);
val->flags = PV_VAL_STR;
val->rs.s = _tr_buffer;