From: Corey Farrell Date: Thu, 15 Nov 2018 20:47:50 +0000 (-0500) Subject: res_pjsip_caller_id: Use static pj_str_t for fromto header names. X-Git-Tag: 16.1.0-rc1~18^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a76489ebaaf2eb727860c96907b00e53a50536a;p=thirdparty%2Fasterisk.git res_pjsip_caller_id: Use static pj_str_t for fromto header names. PJSIP assumes that these header names are not allocated, does not clone the name strings when reusing headers. Block unload of res_pjsip_caller_id until shutdown to ensure static memory stays valid. It was previously unsafe to unload while any sessions are active. Change-Id: I190854dea943d6e441cf03733f8a0da661aea27f --- diff --git a/res/res_pjsip_caller_id.c b/res/res_pjsip_caller_id.c index 1a5fa3c787..20c73da1de 100644 --- a/res/res_pjsip_caller_id.c +++ b/res/res_pjsip_caller_id.c @@ -430,8 +430,7 @@ static pjsip_fromto_hdr *create_new_id_hdr(const pj_str_t *hdr_name, pjsip_fromt id_hdr = pjsip_from_hdr_create(tdata->pool); id_hdr->type = PJSIP_H_OTHER; - pj_strdup(tdata->pool, &id_hdr->name, hdr_name); - id_hdr->sname = id_hdr->name; + id_hdr->sname = id_hdr->name = *hdr_name; id_name_addr = pjsip_uri_clone(tdata->pool, base->uri); id_uri = pjsip_uri_get_uri(id_name_addr->uri); @@ -779,6 +778,7 @@ static struct ast_sip_session_supplement caller_id_supplement = { static int load_module(void) { + ast_module_shutdown_ref(AST_MODULE_SELF); ast_sip_session_register_supplement(&caller_id_supplement); return AST_MODULE_LOAD_SUCCESS; }