Module: kamailio Branch: master Commit: 3dc960b6db3dc5807814fc73887f985bf2ff91d7 URL: https://github.com/kamailio/kamailio/commit/3dc960b6db3dc5807814fc73887f985b...
Author: Victor Seva linuxmaniac@torreviejawireless.org Committer: Victor Seva linuxmaniac@torreviejawireless.org Date: 2020-05-12T14:38:43+02:00
xprint: use ctime_r() for a safer multi-thread usage
The reentrant version ctime_r() does the same, but stores the string in a user-supplied buffer which should have room for at least 26 bytes.
---
Modified: src/modules/xprint/xp_lib.c
---
Diff: https://github.com/kamailio/kamailio/commit/3dc960b6db3dc5807814fc73887f985b... Patch: https://github.com/kamailio/kamailio/commit/3dc960b6db3dc5807814fc73887f985b...
---
diff --git a/src/modules/xprint/xp_lib.c b/src/modules/xprint/xp_lib.c index bbe2ceaafe..5771b77399 100644 --- a/src/modules/xprint/xp_lib.c +++ b/src/modules/xprint/xp_lib.c @@ -164,7 +164,7 @@ static int xl_get_times(struct sip_msg *msg, str *res, str *hp, int hi, int hf) } static int xl_get_timef(struct sip_msg *msg, str *res, str *hp, int hi, int hf) { - char *ch = NULL; + char ch[26] = {0};
if(msg==NULL || res==NULL) return -1; @@ -174,7 +174,7 @@ static int xl_get_timef(struct sip_msg *msg, str *res, str *hp, int hi, int hf) msg_id = msg->id; }
- ch = ctime(&msg_tm); + ctime_r(&msg_tm, ch);
res->s = ch; res->len = strlen(ch)-1;