]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip: Prevent access of NULL channels. 81/581/1
authorMark Michelson <mmichelson@digium.com>
Wed, 3 Jun 2015 22:41:23 +0000 (17:41 -0500)
committerMark Michelson <mmichelson@digium.com>
Wed, 3 Jun 2015 22:41:23 +0000 (17:41 -0500)
It is possible to receive incoming requests or responses after the channel
on an ast_sip_session has been destroyed and NULLed out. Handlers of these
sorts of requests or responses need to be prepared for the possibility
that the channel is NULL or else they could cause a crash.

While several places have been amended to deal with NULL channels, there
were still a couple of places that needed updating.

res_pjsip_dtmf_info.c: When handling incoming INFO requests, we need to
return early if there is no channel on the session.

res_pjsip_session.c: When handling a 302 response, we need to stop the
redirecting attempt if there is no channel on the session.

ASTERISK-25148 #close
reported by Mark Michelson

Change-Id: Id1a75ffc3d0eaa168b0b28188fb54d6cf9fc47a9

res/res_pjsip_dtmf_info.c
res/res_pjsip_session.c

index b6a0b4a1ec4594485fa1e6fcbb419ac8306c62f5..78d529c30b1099e74ce6995ebe8ba62a318c8ea9 100644 (file)
@@ -89,7 +89,13 @@ static int dtmf_info_incoming_request(struct ast_sip_session *session, struct pj
        char event = '\0';
        unsigned int duration = 100;
 
-       char is_dtmf = is_media_type(rdata, "dtmf");
+       char is_dtmf;
+
+       if (!session->channel) {
+               return 0;
+       }
+
+       is_dtmf = is_media_type(rdata, "dtmf");
 
        if (!is_dtmf && !is_media_type(rdata, "dtmf-relay")) {
                return 0;
index 91e3abed8a48aed2ddd9faa4d84c9b7abce176df..bbd74eeb58fb6a1ecce3eb0f436f63c31aa3318e 100644 (file)
@@ -2627,6 +2627,10 @@ static pjsip_redirect_op session_inv_on_redirected(pjsip_inv_session *inv, const
        struct ast_sip_session *session = inv->mod_data[session_module.id];
        const pjsip_sip_uri *uri;
 
+       if (!session->channel) {
+               return PJSIP_REDIRECT_STOP;
+       }
+
        if (session->endpoint->redirect_method == AST_SIP_REDIRECT_URI_PJSIP) {
                return PJSIP_REDIRECT_ACCEPT;
        }