[Asterisk-code-review] chan pjsip: Don't assume a session will have a channel. (asterisk[13])
Joshua Colp
asteriskteam at digium.com
Sun Mar 12 09:33:49 CDT 2017
Joshua Colp has uploaded a new change for review. ( https://gerrit.asterisk.org/5165 )
Change subject: chan_pjsip: Don't assume a session will have a channel.
......................................................................
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
---
M channels/pjsip/dialplan_functions.c
1 file changed, 11 insertions(+), 1 deletion(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/65/5165/1
diff --git a/channels/pjsip/dialplan_functions.c b/channels/pjsip/dialplan_functions.c
index 719a074..533c8a5 100644
--- a/channels/pjsip/dialplan_functions.c
+++ b/channels/pjsip/dialplan_functions.c
@@ -737,16 +737,23 @@
struct pjsip_func_args *func_args = data;
if (!strcmp(func_args->param, "rtp")) {
+ if (!func_args->session->channel) {
+ return -1;
+ }
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) {
+ return -1;
+ }
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));
+ ast_log(AST_LOG_WARNING, "Channel %s has no endpoint!\n", func_args->session->channel ?
+ ast_channel_name(func_args->session->channel) : "<unknown>");
return -1;
}
snprintf(func_args->buf, func_args->len, "%s", ast_sorcery_object_get_id(func_args->session->endpoint));
@@ -761,6 +768,9 @@
}
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) {
+ return -1;
+ }
func_args->ret = channel_read_pjsip(func_args->session->channel, func_args->type,
func_args->field, func_args->buf,
func_args->len);
--
To view, visit https://gerrit.asterisk.org/5165
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I113479cffff6ae64cf8ed089e9e1565223426f01
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
More information about the asterisk-code-review
mailing list