Skip to content
Snippets Groups Projects
Commit 25d74e03 authored by James Golovich's avatar James Golovich
Browse files

More app_read.c fixes (bug 1261)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2518 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent c1c704c0
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment