diff options
author | citats <citats@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-03-22 03:46:19 +0000 |
---|---|---|
committer | citats <citats@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-03-22 03:46:19 +0000 |
commit | b38953a8f3ab2bebc1440126f537bd7e578f8f00 (patch) | |
tree | cb5e9a5764718fded95a19cf8c38f89ecac4e5e7 /apps | |
parent | cc7594028fc2a01550dec12a58285a5c203e8df0 (diff) |
More app_read.c fixes (bug 1261)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2518 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rwxr-xr-x | apps/app_read.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/apps/app_read.c b/apps/app_read.c index 7a5027386..caf847828 100755 --- a/apps/app_read.c +++ b/apps/app_read.c @@ -48,7 +48,7 @@ static int read_exec(struct ast_channel *chan, void *data) int res = 0; struct localuser *u; char tmp[256]; - char tmp2[256]=""; + char *varname; char *filename; char *stringp; char *maxdigitstr; @@ -58,10 +58,12 @@ static int read_exec(struct ast_channel *chan, void *data) return -1; } strncpy(tmp, (char *)data, sizeof(tmp)-1); - stringp=tmp; - strsep(&stringp, "|"); + stringp=(char *)calloc(1,strlen(tmp)+1); + snprintf(stringp,strlen(tmp)+1,"%s",tmp); + varname = strsep(&stringp, "|"); filename = strsep(&stringp, "|"); maxdigitstr = strsep(&stringp,"|"); + if (!(filename) || (strlen(filename)==0)) filename = NULL; if (maxdigitstr) { maxdigits = atoi(maxdigitstr); @@ -71,7 +73,7 @@ static int read_exec(struct ast_channel *chan, void *data) else ast_verbose(VERBOSE_PREFIX_3 "Accepting a maximum of %i digits.\n", maxdigits); } - if (!strlen(tmp)) { + if (!(varname) || (strlen(varname)==0)) { ast_log(LOG_WARNING, "Read requires an variable name\n"); return -1; } @@ -80,12 +82,13 @@ static int read_exec(struct ast_channel *chan, void *data) /* Answer if the line isn't up. */ res = ast_answer(chan); } + strncpy(tmp, (char *)varname, sizeof(tmp)-1); if (!res) { ast_stopstream(chan); - res = ast_app_getdata(chan, filename, tmp2, maxdigits, 0); + res = ast_app_getdata(chan, filename, tmp, maxdigits, 0); if (!res) - pbx_builtin_setvar_helper(chan, tmp, tmp2); - ast_verbose(VERBOSE_PREFIX_3 "User entered '%s'\n", tmp2); + pbx_builtin_setvar_helper(chan, varname, tmp); + ast_verbose(VERBOSE_PREFIX_3 "User entered '%s'\n", tmp); } LOCAL_USER_REMOVE(u); return res; |