[Asterisk-code-review] chan pjsip: Don't assume a session will have a channel. (asterisk[master])
Anonymous Coward
asteriskteam at digium.com
Tue Mar 14 14:07:52 CDT 2017
Anonymous Coward #1000019 has submitted this change and it was merged. ( https://gerrit.asterisk.org/5167 )
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, 16 insertions(+), 2 deletions(-)
Approvals:
George Joseph: Looks good to me, approved
Richard Mudgett: Looks good to me, but someone else must approve
Anonymous Coward #1000019: Verified
diff --git a/channels/pjsip/dialplan_functions.c b/channels/pjsip/dialplan_functions.c
index 17c19b7..332df70 100644
--- a/channels/pjsip/dialplan_functions.c
+++ b/channels/pjsip/dialplan_functions.c
@@ -735,17 +735,27 @@
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")) {
@@ -759,6 +769,10 @@
}
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);
--
To view, visit https://gerrit.asterisk.org/5167
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I113479cffff6ae64cf8ed089e9e1565223426f01
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
More information about the asterisk-code-review
mailing list