mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 03:08:45 +00:00
Fix externalivr's setvariable command so that it properly sets multiple variables.
The command had a for loop that was guaranteed to only execute once since the continuation operation of the loop would set the input buffer NULL. I rewrote the loop so that its operation was more obvious, and it would set multiple variables correctly. I also reduced stack space required for the function, constified the input string, and modified the function so that it would not modify the input string while I was at it. (closes issue #15114) Reported by: chris-mac Patches: 15114.patch uploaded by mmichelson (license 60) Tested by: chris-mac git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@195316 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -282,29 +282,20 @@ static void ast_eivr_getvariable(struct ast_channel *chan, char *data, char *out
|
|||||||
|
|
||||||
static void ast_eivr_setvariable(struct ast_channel *chan, char *data)
|
static void ast_eivr_setvariable(struct ast_channel *chan, char *data)
|
||||||
{
|
{
|
||||||
char buf[1024];
|
|
||||||
char *value;
|
char *value;
|
||||||
|
|
||||||
char *inbuf, *variable;
|
char *inbuf = ast_strdupa(data), *variable;
|
||||||
|
|
||||||
int j;
|
for (variable = strsep(&inbuf, ","); variable; variable = strsep(&inbuf, ",")) {
|
||||||
|
|
||||||
for (j = 1, inbuf = data; ; j++, inbuf = NULL) {
|
|
||||||
variable = strsep(&inbuf, ",");
|
|
||||||
ast_debug(1, "Setting up a variable: %s\n", variable);
|
ast_debug(1, "Setting up a variable: %s\n", variable);
|
||||||
if (variable) {
|
/* variable contains "varname=value" */
|
||||||
/* variable contains "varname=value" */
|
value = strchr(variable, '=');
|
||||||
ast_copy_string(buf, variable, sizeof(buf));
|
if (!value) {
|
||||||
value = strchr(buf, '=');
|
value = "";
|
||||||
if (!value) {
|
|
||||||
value = "";
|
|
||||||
} else {
|
|
||||||
*value++ = '\0';
|
|
||||||
}
|
|
||||||
pbx_builtin_setvar_helper(chan, buf, value);
|
|
||||||
} else {
|
} else {
|
||||||
break;
|
*value++ = '\0';
|
||||||
}
|
}
|
||||||
|
pbx_builtin_setvar_helper(chan, variable, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user