[Asterisk-code-review] core: Fix NPE in ast_manager_build_channel_state_string when snapshot... (asterisk[16])

Robert Sutton asteriskteam at digium.com
Wed Apr 8 19:09:54 CDT 2020


Robert Sutton has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/14144 )


Change subject: core: Fix NPE in ast_manager_build_channel_state_string when snapshot is NULL
......................................................................

core: Fix NPE in ast_manager_build_channel_state_string when snapshot is NULL

There appear to be more than 10 paths where a snapshot is passed to
ast_manager_build_channel_state_string without checking that it is not NULL.

While they could be fixed, it would only lead to re-occurances of this
problem in the future.

As ast_manager_build_channel_state_string may normally return NULL,
a NULL check on snapshot has been added and the method will
return NULL if snapshot is NULL.

A WARNING level log has also been added to help with debugging any future
secondary issues that might arrise.

ASTERISK-28810

Change-Id: I3393e4d521ab6c4551b5434d013a5941706c28de
---
M main/manager_channels.c
1 file changed, 6 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/44/14144/1

diff --git a/main/manager_channels.c b/main/manager_channels.c
index c964033..a50c4f4 100644
--- a/main/manager_channels.c
+++ b/main/manager_channels.c
@@ -493,6 +493,12 @@
 	char *connected_name;
 	int res;
 
+	if (!snapshot)
+	{
+		ast_log(AST_LOG_WARNING, "Call to ast_manager_build_channel_state_string_prefix with NULL snapshot!\n");
+		return NULL;
+	}
+
 	if (snapshot->tech_properties & AST_CHAN_TP_INTERNAL) {
 		return NULL;
 	}

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

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I3393e4d521ab6c4551b5434d013a5941706c28de
Gerrit-Change-Number: 14144
Gerrit-PatchSet: 1
Gerrit-Owner: Robert Sutton <rsutton at noojee.com.au>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200408/4df8b731/attachment.html>


More information about the asterisk-code-review mailing list