[asterisk-commits] gtjoseph: trunk r424449 - in /trunk: ./ main/sorcery.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Oct 3 10:56:00 CDT 2014


Author: gtjoseph
Date: Fri Oct  3 10:55:57 2014
New Revision: 424449

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=424449
Log:
sorcery: Prevent SEGV in sorcery_wizard_create when there's no create function

When you call ast_sorcery_create() you don't necessarily know which wizard is
going to be invoked.  If it happens to be a wizard like 'config' that doesn't
have a 'create' virtual function you get a segfault in the
sorcery_wizard_create callback.  This patch catches the null function pointer,
does an ast_assert, and logs an error.

Review: https://reviewboard.asterisk.org/r/4044/
........

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

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

Modified:
    trunk/   (props changed)
    trunk/main/sorcery.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-13-merged' - no diff available.

Modified: trunk/main/sorcery.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/sorcery.c?view=diff&rev=424449&r1=424448&r2=424449
==============================================================================
--- trunk/main/sorcery.c (original)
+++ trunk/main/sorcery.c Fri Oct  3 10:55:57 2014
@@ -1572,6 +1572,12 @@
 	const struct ast_sorcery_object_wizard *object_wizard = obj;
 	const struct sorcery_details *details = arg;
 
+	if (!object_wizard->wizard->create) {
+		ast_assert(0);
+		ast_log(LOG_ERROR, "Sorcery wizard '%s' doesn't contain a 'create' virtual function.\n",
+			object_wizard->wizard->name);
+		return 0;
+	}
 	return (!object_wizard->caching && !object_wizard->wizard->create(details->sorcery, object_wizard->data, details->obj)) ? CMP_MATCH | CMP_STOP : 0;
 }
 




More information about the asterisk-commits mailing list