]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: lua: bad args are returned for Lua actions
authorThierry FOURNIER <thierry.fournier@ozon.io>
Sun, 6 Jan 2019 18:38:49 +0000 (19:38 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 7 Jan 2019 09:52:46 +0000 (10:52 +0100)
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

src/hlua.c

index a3886cfaae274a2fc54cabbe9ca14361ad224dcb..fcedac6719d4be8ebd93cfb6a3e4d9d702d80b7a 100644 (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;