[svn-commits] qwell: branch 1.4 r105005 - in /branches/1.4/main: cdr.c pbx.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Feb 28 13:20:11 CST 2008


Author: qwell
Date: Thu Feb 28 13:20:10 2008
New Revision: 105005

URL: http://svn.digium.com/view/asterisk?view=rev&rev=105005
Log:
Make pbx_exec pass an empty string into applications, if we get NULL.
This protects against possible segfaults in applications that may try
 to use data before checking length (ast_strdupa'ing it, for example)

(closes issue #12100)
Reported by: foxfire
Patches:
      12100-nullappargs.diff uploaded by qwell (license 4)

Modified:
    branches/1.4/main/cdr.c
    branches/1.4/main/pbx.c

Modified: branches/1.4/main/cdr.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/cdr.c?view=diff&rev=105005&r1=105004&r2=105005
==============================================================================
--- branches/1.4/main/cdr.c (original)
+++ branches/1.4/main/cdr.c Thu Feb 28 13:20:10 2008
@@ -787,12 +787,8 @@
 	for (; cdr; cdr = cdr->next) {
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
 			check_post(cdr);
-			if (!app)
-				app = "";
-			ast_copy_string(cdr->lastapp, app, sizeof(cdr->lastapp));
-			if (!data)
-				data = "";
-			ast_copy_string(cdr->lastdata, data, sizeof(cdr->lastdata));
+			ast_copy_string(cdr->lastapp, S_OR(app, ""), sizeof(cdr->lastapp));
+			ast_copy_string(cdr->lastdata, S_OR(data, ""), sizeof(cdr->lastdata));
 		}
 	}
 }

Modified: branches/1.4/main/pbx.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/pbx.c?view=diff&rev=105005&r1=105004&r2=105005
==============================================================================
--- branches/1.4/main/pbx.c (original)
+++ branches/1.4/main/pbx.c Thu Feb 28 13:20:10 2008
@@ -516,7 +516,7 @@
 	const char *saved_c_appl;
 	const char *saved_c_data;
 
-	if (c->cdr &&  !ast_check_hangup(c))
+	if (c->cdr && !ast_check_hangup(c))
 		ast_cdr_setapp(c->cdr, app->name, data);
 
 	/* save channel values */
@@ -529,7 +529,7 @@
 	if (app->module) {
 		/* XXX LOCAL_USER_ADD(app->module) */
 	}
-	res = app->execute(c, data);
+	res = app->execute(c, S_OR(data, ""));
 	if (app->module) {
 		/* XXX LOCAL_USER_REMOVE(app->module) */
 	}




More information about the svn-commits mailing list