[Asterisk-code-review] func_presencestate: Fix invalid memory access. (asterisk[master])

N A asteriskteam at digium.com
Sun Nov 13 16:17:18 CST 2022


N A has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/19562 )


Change subject: func_presencestate: Fix invalid memory access.
......................................................................

func_presencestate: Fix invalid memory access.

When parsing information from AstDB while loading,
it is possible that certain pointers are never
set, which leads to invalid memory access and
then, fatally, invalid free attempts on this memory.
We now initialize to NULL to prevent this.

ASTERISK-30311 #close

Change-Id: I6120681d04fd2c12a9473f35ce95a1f8e74e3929
---
M funcs/func_presencestate.c
1 file changed, 19 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/62/19562/1

diff --git a/funcs/func_presencestate.c b/funcs/func_presencestate.c
index 6005e48..8aba891 100644
--- a/funcs/func_presencestate.c
+++ b/funcs/func_presencestate.c
@@ -850,8 +850,8 @@
 	for (; db_entry; db_entry = db_entry->next) {
 		const char *dev_name = strrchr(db_entry->key, '/') + 1;
 		enum ast_presence_state state;
-		char *message;
-		char *subtype;
+		char *message = NULL;
+		char *subtype = NULL;
 		if (dev_name <= (const char *) 1) {
 			continue;
 		}

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I6120681d04fd2c12a9473f35ce95a1f8e74e3929
Gerrit-Change-Number: 19562
Gerrit-PatchSet: 1
Gerrit-Owner: N A <asterisk at phreaknet.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20221113/e56f5689/attachment.html>


More information about the asterisk-code-review mailing list