]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Don't limit the size of appdata for manager originate actions.
authorMatthew Nicholson <mnicholson@digium.com>
Tue, 13 Sep 2011 18:20:52 +0000 (18:20 +0000)
committerMatthew Nicholson <mnicholson@digium.com>
Tue, 13 Sep 2011 18:20:52 +0000 (18:20 +0000)
ASTERISK-17709
Patch by: tilghman (with modifications)

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

main/manager.c
main/pbx.c

index 373c43d7d39246d571c8f74acc8b27388e5316dd..12650a819cb276d22fe8c7bf8c78f708fd470d4b 100644 (file)
@@ -81,6 +81,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/features.h"
 #include "asterisk/security_events.h"
 #include "asterisk/aoc.h"
+#include "asterisk/stringfields.h"
 
 /*** DOCUMENTATION
        <manager name="Ping" language="en_US">
@@ -3559,14 +3560,16 @@ struct fast_originate_helper {
        char data[512];
        int timeout;
        format_t format;                                /*!< Codecs used for a call */
-       char app[AST_MAX_APP];
-       char appdata[AST_MAX_EXTENSION];
-       char cid_name[AST_MAX_EXTENSION];
-       char cid_num[AST_MAX_EXTENSION];
-       char context[AST_MAX_CONTEXT];
-       char exten[AST_MAX_EXTENSION];
-       char idtext[AST_MAX_EXTENSION];
-       char account[AST_MAX_ACCOUNT_CODE];
+       AST_DECLARE_STRING_FIELDS (
+               AST_STRING_FIELD(app);
+               AST_STRING_FIELD(appdata);
+               AST_STRING_FIELD(cid_name);
+               AST_STRING_FIELD(cid_num);
+               AST_STRING_FIELD(context);
+               AST_STRING_FIELD(exten);
+               AST_STRING_FIELD(idtext);
+               AST_STRING_FIELD(account);
+       );
        int priority;
        struct ast_variable *vars;
 };
@@ -3617,6 +3620,7 @@ static void *fast_originate(void *data)
        if (chan) {
                ast_channel_unlock(chan);
        }
+       ast_string_field_free_memory(in);
        ast_free(in);
        return NULL;
 }
@@ -3939,29 +3943,30 @@ static int action_originate(struct mansession *s, const struct message *m)
 
        if (ast_true(async)) {
                struct fast_originate_helper *fast = ast_calloc(1, sizeof(*fast));
-               if (!fast) {
+               if (!fast || ast_string_field_init(fast, 252)) {
+                       if (fast) {
+                               ast_free(fast);
+                       }
                        res = -1;
                } else {
-                       if (!ast_strlen_zero(id))
-                               snprintf(fast->idtext, sizeof(fast->idtext), "ActionID: %s", id);
-                       ast_copy_string(fast->tech, tech, sizeof(fast->tech));
-                       ast_copy_string(fast->data, data, sizeof(fast->data));
-                       ast_copy_string(fast->app, app, sizeof(fast->app));
-                       ast_copy_string(fast->appdata, appdata, sizeof(fast->appdata));
-                       if (l) {
-                               ast_copy_string(fast->cid_num, l, sizeof(fast->cid_num));
-                       }
-                       if (n) {
-                               ast_copy_string(fast->cid_name, n, sizeof(fast->cid_name));
+                       if (!ast_strlen_zero(id)) {
+                               ast_string_field_build(fast, idtext, "ActionID: %s", id);
                        }
+                       ast_string_field_set(fast, tech, tech);
+                       ast_string_field_set(fast, data, data);
+                       ast_string_field_set(fast, app, app);
+                       ast_string_field_set(fast, appdata, appdata);
+                       ast_string_field_set(fast, cid_num, l);
+                       ast_string_field_set(fast, cid_name, n);
+                       ast_string_field_set(fast, context, context);
+                       ast_string_field_set(fast, exten, exten);
+                       ast_string_field_set(fast, account, account);
                        fast->vars = vars;
-                       ast_copy_string(fast->context, context, sizeof(fast->context));
-                       ast_copy_string(fast->exten, exten, sizeof(fast->exten));
-                       ast_copy_string(fast->account, account, sizeof(fast->account));
                        fast->format = format;
                        fast->timeout = to;
                        fast->priority = pi;
                        if (ast_pthread_create_detached(&th, NULL, fast_originate, fast)) {
+                               ast_string_field_free_memory(fast);
                                ast_free(fast);
                                res = -1;
                        } else {
index 4e5284042607abd74bf3a277a0277cdb3122a605..fc60710580f6ffe9f47d1ba0cfc49e4289983517 100644 (file)
@@ -8738,10 +8738,12 @@ outgoing_exten_cleanup:
 }
 
 struct app_tmp {
-       char app[256];
-       char data[256];
        struct ast_channel *chan;
        pthread_t t;
+       AST_DECLARE_STRING_FIELDS (
+               AST_STRING_FIELD(app);
+               AST_STRING_FIELD(data);
+       );
 };
 
 /*! \brief run the application and free the descriptor once done */
@@ -8756,6 +8758,7 @@ static void *ast_pbx_run_app(void *data)
        } else
                ast_log(LOG_WARNING, "No such application '%s'\n", tmp->app);
        ast_hangup(tmp->chan);
+       ast_string_field_free_memory(tmp);
        ast_free(tmp);
        return NULL;
 }
@@ -8787,12 +8790,14 @@ int ast_pbx_outgoing_app(const char *type, format_t format, void *data, int time
                                res = 0;
                                ast_verb(4, "Channel %s was answered.\n", chan->name);
                                tmp = ast_calloc(1, sizeof(*tmp));
-                               if (!tmp)
+                               if (!tmp || ast_string_field_init(tmp, 252)) {
+                                       if (tmp) {
+                                               ast_free(tmp);
+                                       }
                                        res = -1;
-                               else {
-                                       ast_copy_string(tmp->app, app, sizeof(tmp->app));
-                                       if (appdata)
-                                               ast_copy_string(tmp->data, appdata, sizeof(tmp->data));
+                               } else {
+                                       ast_string_field_set(tmp, app, app);
+                                       ast_string_field_set(tmp, data, appdata);
                                        tmp->chan = chan;
                                        if (synchronous > 1) {
                                                if (locked_channel)
@@ -8803,6 +8808,7 @@ int ast_pbx_outgoing_app(const char *type, format_t format, void *data, int time
                                                        ast_channel_lock(chan);
                                                if (ast_pthread_create_detached(&tmp->t, NULL, ast_pbx_run_app, tmp)) {
                                                        ast_log(LOG_WARNING, "Unable to spawn execute thread on %s: %s\n", chan->name, strerror(errno));
+                                                       ast_string_field_free_memory(tmp);
                                                        ast_free(tmp);
                                                        if (locked_channel)
                                                                ast_channel_unlock(chan);