summaryrefslogtreecommitdiff
path: root/channels/chan_sip.c
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2015-06-08 11:09:57 -0400
committerCorey Farrell <git@cfware.com>2015-06-08 11:09:57 -0400
commit80621ce3c5da5062f7e3efb42d6e8fcdd9caa3f6 (patch)
tree830f2bf1823901045bccffe224a858ba70b7a9e8 /channels/chan_sip.c
parent8785d0ccbfa1959d1ba6be8769e9d5356f3fef32 (diff)
Fix unsafe uses of ast_context pointers.
Although ast_context_find, ast_context_find_or_create and ast_context_destroy perform locking of the contexts table, any context pointer can become invalid at any time that the contexts table is unlocked. This change adds locking around all complete operations involving these functions. Places where ast_context_find was followed by ast_context_destroy have been replaced with calls ast_context_destroy_by_name. ASTERISK-25094 #close Reported by: Corey Farrell Change-Id: I1866b6787730c9c4f3f836b6133ffe9c820734fa
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r--channels/chan_sip.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 7c4c8a611..1d58a844f 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -19740,8 +19740,7 @@ static void cleanup_stale_contexts(char *new, char *old)
}
}
- if (stalecontext)
- ast_context_destroy(ast_context_find(stalecontext), "SIP");
+ ast_context_destroy_by_name(stalecontext, "SIP");
}
}
@@ -34550,7 +34549,6 @@ static int unload_module(void)
{
struct sip_pvt *p;
struct sip_threadinfo *th;
- struct ast_context *con;
struct ao2_iterator i;
int wait_count;
@@ -34730,10 +34728,7 @@ static int unload_module(void)
close(sipsock);
io_context_destroy(io);
ast_sched_context_destroy(sched);
- con = ast_context_find(used_context);
- if (con) {
- ast_context_destroy(con, "SIP");
- }
+ ast_context_destroy_by_name(used_context, "SIP");
ast_unload_realtime("sipregs");
ast_unload_realtime("sippeers");
ast_cc_monitor_unregister(&sip_cc_monitor_callbacks);