]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
(closes issue #13202)
authorSteve Murphy <murf@digium.com>
Sat, 2 Aug 2008 04:51:29 +0000 (04:51 +0000)
committerSteve Murphy <murf@digium.com>
Sat, 2 Aug 2008 04:51:29 +0000 (04:51 +0000)
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.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@135265 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/features.c
main/pbx.c

index 9724cc85c6e8203d17764270ad4361e3273b5b6a..f540c455b2a081acdbf93ae3a888bd8501433689 100644 (file)
@@ -2911,8 +2911,10 @@ static struct ast_parkinglot *build_parkinglot(char *name, struct ast_variable *
 
        /* 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);
index 7b904c8ff4f16fae28b1cdee9d75e556fbf11360..9772ca53c7f9942ff9887d869c2185a570af7ec9 100644 (file)
@@ -6808,6 +6808,12 @@ int ast_add_extension2(struct ast_context *con,
        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, };