]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: lua: Check argument type to convert it to IPv4/IPv6 arg validation
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 7 Aug 2020 07:07:26 +0000 (09:07 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 7 Aug 2020 12:25:31 +0000 (14:25 +0200)
In hlua_lua2arg_check() function, before converting a string to an IP address,
we must be to sure to have a string argument (ARGT_STR).

This patch must be backported to all supported versions.

src/hlua.c

index 8bc8319446bf0eba809706b8f8c6f650778d8a11..f99bdf9d2059b4f33b6cdc9af427492e38d5af3a 100644 (file)
@@ -741,6 +741,8 @@ __LJMP int hlua_lua2arg_check(lua_State *L, int first, struct arg *argp,
                        break;
 
                case ARGT_IPV4:
+                       if (argp[idx].type != ARGT_STR)
+                               WILL_LJMP(luaL_argerror(L, first + idx, "string expected"));
                        memcpy(trash.area, argp[idx].data.str.area,
                               argp[idx].data.str.data);
                        trash.area[argp[idx].data.str.data] = 0;
@@ -759,6 +761,8 @@ __LJMP int hlua_lua2arg_check(lua_State *L, int first, struct arg *argp,
                        break;
 
                case ARGT_IPV6:
+                       if (argp[idx].type != ARGT_STR)
+                               WILL_LJMP(luaL_argerror(L, first + idx, "string expected"));
                        memcpy(trash.area, argp[idx].data.str.area,
                               argp[idx].data.str.data);
                        trash.area[argp[idx].data.str.data] = 0;