mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 03:20:57 +00:00
res_pjsip_diversion: Use static pj_str_t for Diversion header names
PJSIP assumes that these header names are not allocated, and does not clone the name strings when reusing headers. Block unload of res_pjsip_diversion until shutdown to ensure static memory stays valid. ASTERISK-28312 #close Change-Id: Ibd6ea55ec4a604bbd43ac07f8d0b54da2c39b8b9
This commit is contained in:
@@ -326,8 +326,7 @@ static void add_diversion_header(pjsip_tx_data *tdata, struct ast_party_redirect
|
||||
|
||||
hdr = pjsip_from_hdr_create(tdata->pool);
|
||||
hdr->type = PJSIP_H_OTHER;
|
||||
pj_strdup(tdata->pool, &hdr->name, &diversion_name);
|
||||
hdr->sname = hdr->name;
|
||||
hdr->sname = hdr->name = diversion_name;
|
||||
|
||||
name_addr = pjsip_uri_clone(tdata->pool, base);
|
||||
uri = pjsip_uri_get_uri(name_addr->uri);
|
||||
@@ -414,6 +413,9 @@ static int load_module(void)
|
||||
{
|
||||
CHECK_PJSIP_SESSION_MODULE_LOADED();
|
||||
|
||||
/* Because we are passing static memory to pjsip, we need to make sure it
|
||||
* stays valid while we potentially have active sessions */
|
||||
ast_module_shutdown_ref(ast_module_info->self);
|
||||
ast_sip_session_register_supplement(&diversion_supplement);
|
||||
return AST_MODULE_LOAD_SUCCESS;
|
||||
}
|
||||
|
Reference in New Issue
Block a user