diff options
author | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-05-18 18:58:26 +0000 |
---|---|---|
committer | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-05-18 18:58:26 +0000 |
commit | 64ec870d7b541afa0d1d76eed3b0975f37124e01 (patch) | |
tree | 91b2fa111d7899812851378a8377c731e46149e0 /apps | |
parent | c70e0277d954eb3d781a2f15c9d90f2706a7ac2d (diff) |
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: http://svn.digium.com/svn/asterisk/trunk@195316 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r-- | apps/app_externalivr.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/apps/app_externalivr.c b/apps/app_externalivr.c index 647d55053..5c6cc0a8e 100644 --- a/apps/app_externalivr.c +++ b/apps/app_externalivr.c @@ -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) { - char buf[1024]; char *value; - char *inbuf, *variable; - - int j; + char *inbuf = ast_strdupa(data), *variable; - for (j = 1, inbuf = data; ; j++, inbuf = NULL) { - variable = strsep(&inbuf, ","); + for (variable = strsep(&inbuf, ","); variable; variable = strsep(&inbuf, ",")) { ast_debug(1, "Setting up a variable: %s\n", variable); - if (variable) { - /* variable contains "varname=value" */ - ast_copy_string(buf, variable, sizeof(buf)); - value = strchr(buf, '='); - if (!value) { - value = ""; - } else { - *value++ = '\0'; - } - pbx_builtin_setvar_helper(chan, buf, value); + /* variable contains "varname=value" */ + value = strchr(variable, '='); + if (!value) { + value = ""; } else { - break; + *value++ = '\0'; } + pbx_builtin_setvar_helper(chan, variable, value); } } |