From: Matthew Jordan Date: Mon, 6 Oct 2014 00:51:43 +0000 (+0000) Subject: pjsip/dialplan_functions: Handle PJSIP_MEDIA_OFFER called on non-PJSIP channels X-Git-Tag: 12.7.0-rc1~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=baf255c4c77b3d5d70666ec91b5c7fe8ed5b420c;p=thirdparty%2Fasterisk.git pjsip/dialplan_functions: Handle PJSIP_MEDIA_OFFER called on non-PJSIP channels Calling PJSIP_MEDIA_OFFER on a non-PJSIP channel is hazardous to your health. It will treat the channels as a PJSIP channel, eventually hitting an ao2 error, FRACKing on assertion error, and quite likely crashing. This patch adds checks to the read/write callbacks that ensure that the channel technology is of type 'PJSIP' before attempting to operate on the channel. #SIPit31 ASTERISK-24382 #close Reported by: Matt Jordan git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@424621 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/pjsip/dialplan_functions.c b/channels/pjsip/dialplan_functions.c index c50dbf3fc2..517018b453 100644 --- a/channels/pjsip/dialplan_functions.c +++ b/channels/pjsip/dialplan_functions.c @@ -707,7 +707,7 @@ int pjsip_acf_channel_read(struct ast_channel *chan, const char *cmd, char *data /* Sanity check */ if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) { - ast_log(LOG_ERROR, "Cannot call %s on a non-PJSIP channel\n", cmd); + ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd); return 0; } @@ -876,6 +876,11 @@ int pjsip_acf_media_offer_read(struct ast_channel *chan, const char *cmd, char * return -1; } + if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) { + ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd); + return -1; + } + channel = ast_channel_tech_pvt(chan); if (!strcmp(data, "audio")) { @@ -899,6 +904,11 @@ int pjsip_acf_media_offer_write(struct ast_channel *chan, const char *cmd, char return -1; } + if (strcmp(ast_channel_tech(chan)->type, "PJSIP")) { + ast_log(LOG_WARNING, "Cannot call %s on a non-PJSIP channel\n", cmd); + return -1; + } + channel = ast_channel_tech_pvt(chan); mdata.session = channel->session;