Module: kamailio
Branch: master
Commit: 19769eb372ca4d37ed45fef561cf966360ea6fd4
URL:
https://github.com/kamailio/kamailio/commit/19769eb372ca4d37ed45fef561cf966…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2020-05-12T16:26:07+02:00
pv: use ctime_r() for a safer multi-thread usage
---
Modified: src/modules/pv/pv_time.c
---
Diff:
https://github.com/kamailio/kamailio/commit/19769eb372ca4d37ed45fef561cf966…
Patch:
https://github.com/kamailio/kamailio/commit/19769eb372ca4d37ed45fef561cf966…
---
diff --git a/src/modules/pv/pv_time.c b/src/modules/pv/pv_time.c
index f3baccf6df..87b62b71e9 100644
--- a/src/modules/pv/pv_time.c
+++ b/src/modules/pv/pv_time.c
@@ -246,10 +246,12 @@ int pv_get_timenowf(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
str s;
+ char t_buf[26] = {0};
time_t t;
t = time(NULL);
- s.s = ctime(&t);
+
+ s.s = ctime_r(&t, t_buf);
s.len = strlen(s.s)-1;
return pv_get_strintval(msg, param, res, &s, (int)t);
}
@@ -269,13 +271,14 @@ int pv_get_timef(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
str s;
+ char t_buf[26] = {0};
if(msg==NULL)
return -1;
msg_set_time(msg);
- s.s = ctime(&msg->tval.tv_sec);
+ s.s = ctime_r(&msg->tval.tv_sec, t_buf);
s.len = strlen(s.s)-1;
return pv_get_strintval(msg, param, res, &s, (int)msg->tval.tv_sec);
}