bridge_builtin_features: Add missing channel locks around ast_get_chan_features_gener...
authorRichard Mudgett <rmudgett@digium.com>
Tue, 28 Oct 2014 21:35:41 +0000 (21:35 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Tue, 28 Oct 2014 21:35:41 +0000 (21:35 +0000)
The feature_automonitor() and feature_automixmonitor() functions were not
locking the channel around ast_get_chan_features_general_config().
Accessing the channel datastore list without the channel locked is a good
way to corrupt the list or follow the pointer chain into oblivion.
........

Merged revisions 426531 from http://svn.asterisk.org/svn/asterisk/branches/12
........

Merged revisions 426552 from http://svn.asterisk.org/svn/asterisk/branches/13

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@426553 65c4cc65-6c06-0410-ace0-fbb531ad65f3

bridges/bridge_builtin_features.c

index 503de4c..8ba9a69 100644 (file)
@@ -226,7 +226,9 @@ static int feature_automonitor(struct ast_bridge_channel *bridge_channel, void *
        RAII_VAR(struct ast_channel *, peer_chan, NULL, ast_channel_cleanup);
        RAII_VAR(struct ast_features_general_config *, features_cfg, NULL, ao2_cleanup);
 
+       ast_channel_lock(bridge_channel->chan);
        features_cfg = ast_get_chan_features_general_config(bridge_channel->chan);
+       ast_channel_unlock(bridge_channel->chan);
        ast_bridge_channel_lock_bridge(bridge_channel);
        peer_chan = ast_bridge_peer_nolock(bridge_channel->bridge, bridge_channel->chan);
        ast_bridge_unlock(bridge_channel->bridge);
@@ -412,7 +414,9 @@ static int feature_automixmonitor(struct ast_bridge_channel *bridge_channel, voi
        RAII_VAR(struct ast_channel *, peer_chan, NULL, ast_channel_cleanup);
        RAII_VAR(struct ast_features_general_config *, features_cfg, NULL, ao2_cleanup);
 
+       ast_channel_lock(bridge_channel->chan);
        features_cfg = ast_get_chan_features_general_config(bridge_channel->chan);
+       ast_channel_unlock(bridge_channel->chan);
        ast_bridge_channel_lock_bridge(bridge_channel);
        peer_chan = ast_bridge_peer_nolock(bridge_channel->bridge, bridge_channel->chan);
        ast_bridge_unlock(bridge_channel->bridge);