Module: kamailio
Branch: master
Commit: a05d313e0fa27952d7b10329ca1da9b041369ffb
URL:
https://github.com/kamailio/kamailio/commit/a05d313e0fa27952d7b10329ca1da9b…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2020-05-12T16:08:21+02:00
sipdump: use localtime_r() for a safer multi-thread usage
---
Modified: src/modules/sipdump/sipdump_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/a05d313e0fa27952d7b10329ca1da9b…
Patch:
https://github.com/kamailio/kamailio/commit/a05d313e0fa27952d7b10329ca1da9b…
---
diff --git a/src/modules/sipdump/sipdump_mod.c b/src/modules/sipdump/sipdump_mod.c
index e61fea014d..a9868462e7 100644
--- a/src/modules/sipdump/sipdump_mod.c
+++ b/src/modules/sipdump/sipdump_mod.c
@@ -204,10 +204,11 @@ typedef struct sipdump_info {
int sipdump_buffer_write(sipdump_info_t *sdi, str *obuf)
{
struct timeval tv;
- struct tm *ti;
+ struct tm ti;
+ char t_buf[26] = {0};
gettimeofday(&tv, NULL);
- ti = localtime(&tv.tv_sec);
+ localtime_r(&tv.tv_sec, &ti);
obuf->len = snprintf(_sipdump_wbuf, SIPDUMP_WBUF_SIZE,
"====================\n"
"tag: %.*s\n"
@@ -227,7 +228,7 @@ int sipdump_buffer_write(sipdump_info_t *sdi, str *obuf)
my_pid(),
process_no,
(unsigned long)tv.tv_sec, (unsigned long)tv.tv_usec,
- asctime(ti),
+ asctime_r(&ti, t_buf),
sdi->proto.len, sdi->proto.s, sdi->af.len, sdi->af.s,
sdi->src_ip.len, sdi->src_ip.s, sdi->src_port,
sdi->dst_ip.len, sdi->dst_ip.s, sdi->dst_port,