summaryrefslogtreecommitdiff
path: root/channels/pjsip/dialplan_functions.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2017-03-12 14:21:16 +0000
committerJoshua Colp <jcolp@digium.com>2017-03-13 18:37:31 +0000
commitc8d1b915d74740caea6e99329126a3aa5d73ad4c (patch)
tree8e1d1ad82a3bdce91f94379f1db0dbec9db851ae /channels/pjsip/dialplan_functions.c
parenta860bf63e15b6a7baf8067f34ea38bd4cbee128d (diff)
chan_pjsip: Don't assume a session will have a channel.
When querying for PJSIP specific information using the dialplan function CHANNEL() it is possible that the underlying session will no longer have a channel associated with it. This is most likely to occur when the RTCP HEP module attempts to get the channel name. If this happens then a crash will occur. This change just adds a check that the channel exists on the session before querying it. ASTERISK-26857 Change-Id: I113479cffff6ae64cf8ed089e9e1565223426f01
Diffstat (limited to 'channels/pjsip/dialplan_functions.c')
-rw-r--r--channels/pjsip/dialplan_functions.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/channels/pjsip/dialplan_functions.c b/channels/pjsip/dialplan_functions.c
index 719a0747c..652a6b7f3 100644
--- a/channels/pjsip/dialplan_functions.c
+++ b/channels/pjsip/dialplan_functions.c
@@ -737,17 +737,27 @@ static int read_pjsip(void *data)
struct pjsip_func_args *func_args = data;
if (!strcmp(func_args->param, "rtp")) {
+ if (!func_args->session->channel) {
+ func_args->ret = -1;
+ return 0;
+ }
func_args->ret = channel_read_rtp(func_args->session->channel, func_args->type,
func_args->field, func_args->buf,
func_args->len);
} else if (!strcmp(func_args->param, "rtcp")) {
+ if (!func_args->session->channel) {
+ func_args->ret = -1;
+ return 0;
+ }
func_args->ret = channel_read_rtcp(func_args->session->channel, func_args->type,
func_args->field, func_args->buf,
func_args->len);
} else if (!strcmp(func_args->param, "endpoint")) {
if (!func_args->session->endpoint) {
- ast_log(AST_LOG_WARNING, "Channel %s has no endpoint!\n", ast_channel_name(func_args->session->channel));
- return -1;
+ ast_log(AST_LOG_WARNING, "Channel %s has no endpoint!\n", func_args->session->channel ?
+ ast_channel_name(func_args->session->channel) : "<unknown>");
+ func_args->ret = -1;
+ return 0;
}
snprintf(func_args->buf, func_args->len, "%s", ast_sorcery_object_get_id(func_args->session->endpoint));
} else if (!strcmp(func_args->param, "contact")) {
@@ -761,6 +771,10 @@ static int read_pjsip(void *data)
}
snprintf(func_args->buf, func_args->len, "%s", ast_sorcery_object_get_id(func_args->session->aor));
} else if (!strcmp(func_args->param, "pjsip")) {
+ if (!func_args->session->channel) {
+ func_args->ret = -1;
+ return 0;
+ }
func_args->ret = channel_read_pjsip(func_args->session->channel, func_args->type,
func_args->field, func_args->buf,
func_args->len);