[asterisk-commits] mjordan: branch group/media_formats-reviewed-trunk r418567 - /team/group/medi...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jul 13 21:04:02 CDT 2014


Author: mjordan
Date: Sun Jul 13 21:03:59 2014
New Revision: 418567

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=418567
Log:
media_formats: Prevent crash during masquerade

When a masquerade occurs, a newly created channel replaces an existing channel
and steals its private data structure. This includes swapping the formats and
capabilities.

Since the newly created channel only contains ast_format_none, this causes an
assert to fire when the masqueraded channel is destroyed.

Removing the assert isn't a good idea. However, there's also no real need to
do the accessing that fires the asserts either: the masqueraded channel will
be destroyed, the references will be cleaned up appropriately, and life will go
on. free_translation is also called in a channel destructor, and again, things
will be cleaned up appropriately without going through the accessors that have
the asserts.

https://reviewboard.asterisk.org/r/3753/

Modified:
    team/group/media_formats-reviewed-trunk/main/channel.c

Modified: team/group/media_formats-reviewed-trunk/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/main/channel.c?view=diff&rev=418567&r1=418566&r2=418567
==============================================================================
--- team/group/media_formats-reviewed-trunk/main/channel.c (original)
+++ team/group/media_formats-reviewed-trunk/main/channel.c Sun Jul 13 21:03:59 2014
@@ -2565,22 +2565,14 @@
 
 static void free_translation(struct ast_channel *clonechan)
 {
-	if (ast_channel_writetrans(clonechan))
+	if (ast_channel_writetrans(clonechan)) {
 		ast_translator_free_path(ast_channel_writetrans(clonechan));
-	if (ast_channel_readtrans(clonechan))
+	}
+	if (ast_channel_readtrans(clonechan)) {
 		ast_translator_free_path(ast_channel_readtrans(clonechan));
+	}
 	ast_channel_writetrans_set(clonechan, NULL);
 	ast_channel_readtrans_set(clonechan, NULL);
-	if (!ast_format_cap_count(ast_channel_nativeformats(clonechan))) {
-		ast_channel_set_rawwriteformat(clonechan, NULL);
-		ast_channel_set_rawreadformat(clonechan, NULL);
-	} else {
-		struct ast_format *tmpfmt;
-		tmpfmt = ast_format_cap_get_format(ast_channel_nativeformats(clonechan), 0);
-		ast_channel_set_rawwriteformat(clonechan, tmpfmt);
-		ast_channel_set_rawreadformat(clonechan, tmpfmt);
-		ao2_cleanup(tmpfmt);
-	}
 }
 
 void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force)




More information about the asterisk-commits mailing list