aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_minivm.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-04-30 19:21:04 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-04-30 19:21:04 +0000
commit712c72b0df2fb7badefffb68c319f4a105ae9c71 (patch)
tree89d592fc9e276ed41a21062589ea44fedcf6d0d2 /apps/app_minivm.c
parent829d44846c2cbb8f568e5368c8e033daba211ae0 (diff)
Lock around variables retrieved, and copy the values, if they stay persistent,
since another thread could remove them. (closes issue #12541) Reported by: snuffy Patches: bug_12156_apps.diff uploaded by snuffy (license 35) Several additional changes by me git-svn-id: http://svn.digium.com/svn/asterisk/trunk@114904 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_minivm.c')
-rw-r--r--apps/app_minivm.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/apps/app_minivm.c b/apps/app_minivm.c
index 8a66a9579..8746aca5b 100644
--- a/apps/app_minivm.c
+++ b/apps/app_minivm.c
@@ -1412,7 +1412,12 @@ static int notify_new_message(struct ast_channel *chan, const char *templatename
/* Read counter if available */
- counter = pbx_builtin_getvar_helper(chan, "MVM_COUNTER");
+ ast_channel_lock(chan);
+ if ((counter = pbx_builtin_getvar_helper(chan, "MVM_COUNTER"))) {
+ counter = ast_strdupa(counter);
+ }
+ ast_channel_unlock(chan);
+
if (ast_strlen_zero(counter)) {
ast_debug(2, "-_-_- MVM_COUNTER not found\n");
} else {
@@ -1659,14 +1664,24 @@ static int minivm_notify_exec(struct ast_channel *chan, void *data)
pbx_builtin_setvar_helper(chan, "MINIVM_NOTIFY_STATUS", "FAILED");
return -1;
}
-
- filename = pbx_builtin_getvar_helper(chan, "MVM_FILENAME");
- format = pbx_builtin_getvar_helper(chan, "MVM_FORMAT");
- duration_string = pbx_builtin_getvar_helper(chan, "MVM_DURATION");
+
+ ast_channel_lock(chan);
+ if ((filename = pbx_builtin_getvar_helper(chan, "MVM_FILENAME"))) {
+ filename = ast_strdupa(filename);
+ }
+ ast_channel_unlock(chan);
/* Notify of new message to e-mail and pager */
if (!ast_strlen_zero(filename)) {
+ ast_channel_lock(chan);
+ if ((format = pbx_builtin_getvar_helper(chan, "MVM_FORMAT"))) {
+ format = ast_strdupa(format);
+ }
+ if ((duration_string = pbx_builtin_getvar_helper(chan, "MVM_DURATION"))) {
+ duration_string = ast_strdupa(duration_string);
+ }
+ ast_channel_unlock(chan);
res = notify_new_message(chan, template, vmu, filename, atoi(duration_string), format, chan->cid.cid_num, chan->cid.cid_name);
- };
+ }
pbx_builtin_setvar_helper(chan, "MINIVM_NOTIFY_STATUS", res == 0 ? "SUCCESS" : "FAILED");
@@ -1928,10 +1943,13 @@ static int minivm_delete_exec(struct ast_channel *chan, void *data)
int res = 0;
char filename[BUFSIZ];
- if (!ast_strlen_zero(data))
+ if (!ast_strlen_zero(data)) {
ast_copy_string(filename, (char *) data, sizeof(filename));
- else
+ } else {
+ ast_channel_lock(chan);
ast_copy_string(filename, pbx_builtin_getvar_helper(chan, "MVM_FILENAME"), sizeof(filename));
+ ast_channel_unlock(chan);
+ }
if (ast_strlen_zero(filename)) {
ast_log(LOG_ERROR, "No filename given in application arguments or channel variable MVM_FILENAME\n");