MINOR: hlua: Don't needlessly copy lua strings in trash during args validation
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 6 Aug 2020 06:29:18 +0000 (08:29 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 11 Aug 2020 09:37:28 +0000 (11:37 +0200)
commit5f68a42fdd103be1c267e343651359a28495d2aa
tree36c9bfb25aff476891ab39b7f1b646d2f4b451d4
parent1f02e529ad337243931edb33ce6777b6f3a1c3a7
MINOR: hlua: Don't needlessly copy lua strings in trash during args validation

Lua strings are NULL terminated. So in the hlua_lua2arg_check() function, used
to check arguments against the sample fetches specification, there is no reason
to copy these strings in a trash to add a terminating null byte.

In addition, when the array of arguments is built from lua values, we must take
care to count this terminating null bytes in the size of the buffer where a
string is stored. The same must be done when a sample is built from a lua value.

This patch may be backported to easy backports.

(cherry picked from commit fdea1b6319bc014320a18ba7b7043ba0694dd0dd)
[wt: backported for next commit]
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit f657d400b442b83d1565579c2b78eba9d4e12abc)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/hlua.c