summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Harwell <kharwell@digium.com>2015-02-11 18:02:08 +0000
committerKevin Harwell <kharwell@digium.com>2015-02-11 18:02:08 +0000
commite8ec15a9ef019d0dcfa875a5f08b9e1277fe701d (patch)
treed4aebb686c78109c2f27ff87447244e66b78c687
parente64d151fae43babc138640adaa59b3b0b2eadb28 (diff)
res_pjsip: dtls_handler causes Asterisk to crash
There have been a couple of times where a crash occurred in the dtls_handler section of the code for res_pjsip. Unfortunately, in working this issue the problem was unable to be reproduced. After looking at the backtraces and through the code the current best guess as to why this happened might be due to a reentrance problem and the strtok function. So, the current fix is to convert the strtok function into the reentrant version of the function, strtok_r. ASTERISK-24741 #close Reported by: Zane Conkle Review: https://reviewboard.asterisk.org/r/4409/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@431698 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--res/res_pjsip/pjsip_configuration.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c
index 1518bcee9..60b82eedc 100644
--- a/res/res_pjsip/pjsip_configuration.c
+++ b/res/res_pjsip/pjsip_configuration.c
@@ -646,15 +646,15 @@ static int dtls_handler(const struct aco_option *opt,
{
struct ast_sip_endpoint *endpoint = obj;
char *name = ast_strdupa(var->name);
- char *front, *buf = name;
+ char *front, *back, *buf = name;
/* strip out underscores in the name */
- front = strtok(buf, "_");
+ front = strtok_r(buf, "_", &back);
while (front) {
int size = strlen(front);
ast_copy_string(buf, front, size + 1);
buf += size;
- front = strtok(NULL, "_");
+ front = strtok_r(NULL, "_", &back);
}
return ast_rtp_dtls_cfg_parse(&endpoint->media.rtp.dtls_cfg, name, var->value);