[asterisk-commits] jrose: branch 1.8 r377256 - /branches/1.8/res/res_srtp.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Dec 5 10:46:35 CST 2012


Author: jrose
Date: Wed Dec  5 10:46:28 2012
New Revision: 377256

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=377256
Log:
res_srtp: Fix a crash caused by srtp_dealloc on an already dealloced session

When srtp_create fails, the session may be dealloced or just not alloced. At
the same time though, the session pointer might not be set to NULL in this
process and attempting to srtp_dealloc it again will cause a segfault. This
patch checks for failure of srtp_create and sets the session pointer to NULL
if it fails.

(closes issue ASTERISK-20499)
Reported by: tootai
Review: https://reviewboard.asterisk.org/r/2228/

Modified:
    branches/1.8/res/res_srtp.c

Modified: branches/1.8/res/res_srtp.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/res/res_srtp.c?view=diff&rev=377256&r1=377255&r2=377256
==============================================================================
--- branches/1.8/res/res_srtp.c (original)
+++ branches/1.8/res/res_srtp.c Wed Dec  5 10:46:28 2012
@@ -383,6 +383,8 @@
 					retry++;
 					ao2_iterator_destroy(&it);
 					goto tryagain;
+				} else {
+					srtp->session = NULL;
 				}
 				ao2_t_ref(policy, -1, "Unreffing first policy after srtp_create failed");
 			}
@@ -437,6 +439,8 @@
 
 	/* Any failures after this point can use ast_srtp_destroy to destroy the instance */
 	if (srtp_create(&temp->session, &policy->sp) != err_status_ok) {
+		/* Session either wasn't created or was created and dealloced. */
+		temp->session = NULL;
 		ast_srtp_destroy(temp);
 		return -1;
 	}




More information about the asterisk-commits mailing list