]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Make pbx_exec pass an empty string into applications, if we get NULL.
authorJason Parker <jparker@digium.com>
Thu, 28 Feb 2008 19:20:10 +0000 (19:20 +0000)
committerJason Parker <jparker@digium.com>
Thu, 28 Feb 2008 19:20:10 +0000 (19:20 +0000)
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)

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

main/cdr.c
main/pbx.c

index b3fcf08ee516f983adb26e9fcfeceb2d4b341835..ee0086444ad5b384b73bd9838acc6ab00bc0a039 100644 (file)
@@ -787,12 +787,8 @@ void ast_cdr_setapp(struct ast_cdr *cdr, char *app, char *data)
        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));
                }
        }
 }
index e1a2d2e878eb71ea328f29e9c35ff2b2ab06ce91..05e3b2d451ff3ce193bf0f6feb44af1a8ed7a257 100644 (file)
@@ -516,7 +516,7 @@ int pbx_exec(struct ast_channel *c,                 /*!< Channel */
        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 @@ int pbx_exec(struct ast_channel *c,                 /*!< Channel */
        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) */
        }