BUG/MINOR: lua: bad args are returned for Lua actions

In tcp actions case, the argument n - 1 is returned. For example:

  http-request lua.script stuff

display "stuff" as first arg

  tcp-request content lua.script stuff

display "lua.script" as first arg

The action parser doesn't use the *cur_arg value.

Thanks to Andy Franks for the bug report.

This patch mist be backported in haproxy-1.8 and haproxy-1.9
This commit is contained in:
Thierry FOURNIER 2019-01-06 19:38:49 +01:00 committed by Willy Tarreau
parent 7778b59be1
commit 1725c2e395

View File

@ -7641,11 +7641,11 @@ static enum act_parse_ret action_register_lua(const char **args, int *cur_arg, s
/* Expect some arguments */
for (i = 0; i < fcn->nargs; i++) {
if (*args[i+1] == '\0') {
if (*args[*cur_arg] == '\0') {
memprintf(err, "expect %d arguments", fcn->nargs);
return ACT_RET_PRS_ERR;
}
rule->arg.hlua_rule->args[i] = strdup(args[i + 1]);
rule->arg.hlua_rule->args[i] = strdup(args[*cur_arg]);
if (!rule->arg.hlua_rule->args[i]) {
memprintf(err, "out of memory error");
return ACT_RET_PRS_ERR;