[Asterisk-code-review] res_stasis_snoop: Fix snoop crash (asterisk[master])

sungtae kim asteriskteam at digium.com
Wed Jan 4 06:47:14 CST 2023


sungtae kim has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/19781 )


Change subject: res_stasis_snoop: Fix snoop crash
......................................................................

res_stasis_snoop: Fix snoop crash

Added NULL pointer check and channel lock to prevent resource release while
the chanspy is processing.

Change-Id: Ibdc675f98052da32333b19685b1708a3751b6d24
---
M res/res_stasis_snoop.c
1 file changed, 21 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/81/19781/1

diff --git a/res/res_stasis_snoop.c b/res/res_stasis_snoop.c
index 70cdd7c..28a0e70 100644
--- a/res/res_stasis_snoop.c
+++ b/res/res_stasis_snoop.c
@@ -129,15 +129,21 @@
 		return;
 	}
 
+	ast_channel_lock(snoop->chan);
 	snoop_snapshot = ast_channel_snapshot_get_latest(ast_channel_uniqueid(snoop->chan));
+	ast_channel_unlock(snoop->chan);
 	if (!snoop_snapshot) {
 		return;
 	}
 	ast_multi_channel_blob_add_channel(payload, "spyer_channel", snoop_snapshot);
 
-	spyee_snapshot = ast_channel_snapshot_get_latest(ast_channel_uniqueid(snoop->spyee_chan));
-	if (spyee_snapshot) {
-		ast_multi_channel_blob_add_channel(payload, "spyee_channel", spyee_snapshot);
+	if (snoop->spyee_chan) {
+		ast_channel_lock(snoop->spyee_chan);
+		spyee_snapshot = ast_channel_snapshot_get_latest(ast_channel_uniqueid(snoop->spyee_chan));
+		ast_channel_unlock(snoop->spyee_chan);
+		if (spyee_snapshot) {
+			ast_multi_channel_blob_add_channel(payload, "spyee_channel", spyee_snapshot);
+		}
 	}
 
 	message = stasis_message_create(type, payload);

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19781
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ibdc675f98052da32333b19685b1708a3751b6d24
Gerrit-Change-Number: 19781
Gerrit-PatchSet: 1
Gerrit-Owner: sungtae kim <pchero21 at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20230104/7c552d78/attachment-0001.html>


More information about the asterisk-code-review mailing list