[asterisk-commits] murf: trunk r135265 - in /trunk/main: features.c pbx.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 1 23:51:30 CDT 2008


Author: murf
Date: Fri Aug  1 23:51:29 2008
New Revision: 135265

URL: http://svn.digium.com/view/asterisk?view=rev&rev=135265
Log:
(closes issue #13202)
Reported by: falves11
Tested by: murf

falves11 ==

The changes I introduce here seem to clear up the problem
for me. However, if they do not for you, please reopen this
bug, and we'll keep digging.

The root of this problem seems to be a subtle memory corruption
introduced when creating an extension with an empty extension
name. While valgrind cannot detect it outside of DEBUG_MALLOC
mode, when compiled with DEBUG_MALLOC, this is certain death.

The code in main/features.c is a puzzle to me. On the initial
module load, the code is attempting to add the parking extension
before the features.conf file has even been opened!

I just wrapped the offending call with an if() that will not
try to add the extension if the extension name is empty. THis
seems to solve the corruption, and let the "memory show allocations"
work as one would expect.

But, really, adding an extension with an empty name is a seriously
bad thing to allow, as it will mess up all the pattern matching 
algorithms, etc. So, I added a statement to the add_extension2 code to return
a -1 if this is attempted.



Modified:
    trunk/main/features.c
    trunk/main/pbx.c

Modified: trunk/main/features.c
URL: http://svn.digium.com/view/asterisk/trunk/main/features.c?view=diff&rev=135265&r1=135264&r2=135265
==============================================================================
--- trunk/main/features.c (original)
+++ trunk/main/features.c Fri Aug  1 23:51:29 2008
@@ -2911,8 +2911,10 @@
 
 	/* Add a parking extension into the context */
 	if (!oldparkinglot) {
-		if (ast_add_extension2(con, 1, ast_parking_ext(), 1, NULL, NULL, parkcall, strdup(""), ast_free, registrar) == -1)
-			error = 1;
+		if (!ast_strlen_zero(ast_parking_ext())) {
+			if (ast_add_extension2(con, 1, ast_parking_ext(), 1, NULL, NULL, parkcall, strdup(""), ast_free, registrar) == -1)
+				error = 1;
+		}
 	}
 
 	ao2_unlock(parkinglot);

Modified: trunk/main/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/main/pbx.c?view=diff&rev=135265&r1=135264&r2=135265
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Fri Aug  1 23:51:29 2008
@@ -6808,6 +6808,12 @@
 	struct ast_exten dummy_exten = {0};
 	char dummy_name[1024];
 
+	if (ast_strlen_zero(extension)) {
+		ast_log(LOG_ERROR,"You have to be kidding-- add exten '' to context %s? Figure out a name and call me back. Action ignored.\n",
+				con->name);
+		return -1;
+	}
+	
 	/* If we are adding a hint evalulate in variables and global variables */
 	if (priority == PRIORITY_HINT && strstr(application, "${") && !strstr(extension, "_")) {
 		struct ast_channel c = {0, };




More information about the asterisk-commits mailing list