From ddd02c0303b281183c37db5617a2d9c78265492f Mon Sep 17 00:00:00 2001 From: Joshua Colp Date: Thu, 25 Jul 2013 20:54:17 +0000 Subject: Fix crash due to trying to send a re-invite while in the incorrect state. This crash would occur if a re-invite was queued while the initial INVITE transaction was still occurring and the response to the INVITE was not ACKed. This lack of ACK would cause the INVITE session state to never reach confirmed. Once the transaction terminated, however, the queued re-invite would occur and cause a crash due to this lack of state change. This fix checks the INVITE session state before performing the re-invite to ensure it is in the required confirmed state. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395455 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- res/res_sip_session.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'res') diff --git a/res/res_sip_session.c b/res/res_sip_session.c index 21308f8ad..402b791f2 100644 --- a/res/res_sip_session.c +++ b/res/res_sip_session.c @@ -716,11 +716,20 @@ int ast_sip_session_refresh(struct ast_sip_session *session, return 0; } - if ((method == AST_SIP_SESSION_REFRESH_METHOD_INVITE) && inv_session->invite_tsx) { - /* We can't send a reinvite yet, so delay it */ - ast_debug(3, "Delaying sending reinvite to %s because of outstanding transaction...\n", - ast_sorcery_object_get_id(session->endpoint)); - return delay_request(session, on_request_creation, on_response, "INVITE", NULL); + if (method == AST_SIP_SESSION_REFRESH_METHOD_INVITE) { + if (inv_session->invite_tsx) { + /* We can't send a reinvite yet, so delay it */ + ast_debug(3, "Delaying sending reinvite to %s because of outstanding transaction...\n", + ast_sorcery_object_get_id(session->endpoint)); + return delay_request(session, on_request_creation, on_response, "INVITE", NULL); + } else if (inv_session->state != PJSIP_INV_STATE_CONFIRMED) { + /* Initial INVITE transaction failed to progress us to a confirmed state + * which means re-invites are not possible + */ + ast_debug(3, "Not sending reinvite to %s because not in confirmed state...\n", + ast_sorcery_object_get_id(session->endpoint)); + return 0; + } } if (generate_new_sdp) { -- cgit v1.2.3