diff options
author | Richard Mudgett <rmudgett@digium.com> | 2012-05-08 20:32:11 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2012-05-08 20:32:11 +0000 |
commit | 9cd0236f61c2725a6b56c9cd66ef01f886f4aae6 (patch) | |
tree | ade4e6262db45977b3cf38ad1f0df9cb737e371a /apps/app_followme.c | |
parent | 1b0428ac7d6fb0748f0037552348540245780671 (diff) |
* Fix FollowMe memory leak on error paths in app_exec().
* Fix FollowMe leaving recorded caller name file on error paths in
app_exec().
* Use correct buffer dimension define in struct fm_args.namerecloc[].
This fixes unexpected namerecloc filename length restriction.
........
Merged revisions 365692 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 365701 from http://svn.asterisk.org/svn/asterisk/branches/10
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@365707 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_followme.c')
-rw-r--r-- | apps/app_followme.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/apps/app_followme.c b/apps/app_followme.c index 333494fa0..f2f29f86b 100644 --- a/apps/app_followme.c +++ b/apps/app_followme.c @@ -169,7 +169,7 @@ struct fm_args { unsigned int pending_out_connected_update:1; int status; char context[AST_MAX_CONTEXT]; - char namerecloc[AST_MAX_CONTEXT]; + char namerecloc[PATH_MAX]; char takecall[MAX_YN_STRING]; /*!< Digit mapping to take a call */ char nextindp[MAX_YN_STRING]; /*!< Digit mapping to decline a call */ char callfromprompt[PATH_MAX]; /*!< Sound prompt name and path */ @@ -1151,7 +1151,6 @@ static int app_exec(struct ast_channel *chan, const char *data) struct number *nm, *newnm; int res = 0; char *argstr; - char namerecloc[255]; struct ast_channel *caller; struct ast_channel *outbound; AST_DECLARE_APP_ARGS(args, @@ -1223,7 +1222,6 @@ static int app_exec(struct ast_channel *chan, const char *data) ast_clear_flag(&targs.followmeflags, FOLLOWMEFLAG_NOANSWER); } - namerecloc[0] = '\0'; if (ast_test_flag(&targs.followmeflags, FOLLOWMEFLAG_NOANSWER)) { ast_indicate(chan, AST_CONTROL_RINGING); } else { @@ -1238,14 +1236,14 @@ static int app_exec(struct ast_channel *chan, const char *data) if (ast_test_flag(&targs.followmeflags, FOLLOWMEFLAG_RECORDNAME)) { int duration = 5; - snprintf(namerecloc, sizeof(namerecloc), "%s/followme.%s", + snprintf(targs.namerecloc, sizeof(targs.namerecloc), "%s/followme.%s", ast_config_AST_SPOOL_DIR, ast_channel_uniqueid(chan)); - if (ast_play_and_record(chan, "vm-rec-name", namerecloc, 5, "sln", &duration, + if (ast_play_and_record(chan, "vm-rec-name", targs.namerecloc, 5, "sln", &duration, NULL, ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE), 0, NULL) < 0) { goto outrun; } - if (!ast_fileexists(namerecloc, NULL, ast_channel_language(chan))) { - namerecloc[0] = '\0'; + if (!ast_fileexists(targs.namerecloc, NULL, ast_channel_language(chan))) { + targs.namerecloc[0] = '\0'; } } @@ -1260,19 +1258,11 @@ static int app_exec(struct ast_channel *chan, const char *data) targs.status = 0; targs.chan = chan; - ast_copy_string(targs.namerecloc, namerecloc, sizeof(targs.namerecloc)); ast_channel_lock(chan); ast_connected_line_copy_from_caller(&targs.connected_in, ast_channel_caller(chan)); ast_channel_unlock(chan); findmeexec(&targs); - - while ((nm = AST_LIST_REMOVE_HEAD(&targs.cnumbers, entry))) - ast_free(nm); - - if (!ast_strlen_zero(namerecloc)) - unlink(namerecloc); - if (targs.status != 100) { if (ast_test_flag(&targs.followmeflags, FOLLOWMEFLAG_NOANSWER)) { if (ast_channel_state(chan) != AST_STATE_UP) { @@ -1337,8 +1327,15 @@ static int app_exec(struct ast_channel *chan, const char *data) } outrun: + while ((nm = AST_LIST_REMOVE_HEAD(&targs.cnumbers, entry))) { + ast_free(nm); + } + if (!ast_strlen_zero(targs.namerecloc)) { + unlink(targs.namerecloc); + } ast_party_connected_line_free(&targs.connected_in); ast_party_connected_line_free(&targs.connected_out); + if (f->realtime) { /* Not in list */ free_numbers(f); |