[Asterisk-code-review] loader.c: Fix possible SEGV when a module fails to register (...asterisk[16])

George Joseph asteriskteam at digium.com
Wed Jul 31 06:43:48 CDT 2019


George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/asterisk/+/11637 )

Change subject: loader.c:  Fix possible SEGV when a module fails to register
......................................................................

loader.c:  Fix possible SEGV when a module fails to register

When a module fails to register itself (usually a coding error
in the module), dlerror() can return NULL.  We weren't checking
for that in load_dlopen() before trying to strdup the error message
so a SEGV was thrown.  dlerror() is now surrounded with an S_OR
so we don't SEGV.

Change-Id: Ie0fb9316f08a321434f3f85aecf3c7d2ede8b956
---
M main/loader.c
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Corey Farrell: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved; Approved for Submit



diff --git a/main/loader.c b/main/loader.c
index b46f745..033693e 100644
--- a/main/loader.c
+++ b/main/loader.c
@@ -1087,7 +1087,7 @@
 	if (resource_being_loaded) {
 		struct ast_str *list;
 		int c = 0;
-		const char *dlerror_msg = ast_strdupa(dlerror());
+		const char *dlerror_msg = ast_strdupa(S_OR(dlerror(), ""));
 
 		resource_being_loaded = NULL;
 		if (mod->lib) {

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

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: Ie0fb9316f08a321434f3f85aecf3c7d2ede8b956
Gerrit-Change-Number: 11637
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190731/c24f7762/attachment.html>


More information about the asterisk-code-review mailing list