BUG/MINOR: lua: Check argument type to convert it to IPv4/IPv6 arg validation
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.
(cherry picked from commit 8e09ac8592cb35e11bff0f821db19369e0941e35)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit af6bd3010aac6565e98e61d6bb1ea973f0f271d4)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 63a92c32004e634bdd41eb4d446d74e2a8a4e5a9)
Signed-off-by: Willy Tarreau <w@1wt.eu>
diff --git a/src/hlua.c b/src/hlua.c
index c2d045e..9eaa10b 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -754,6 +754,8 @@
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;
@@ -772,6 +774,8 @@
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;