BUG/MINOR: lua: use strlcpy2() not strncpy() to copy sample keywords
authorWilly Tarreau <w@1wt.eu>
Thu, 26 Aug 2021 14:48:53 +0000 (16:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 3 Sep 2021 14:28:34 +0000 (16:28 +0200)
commitabb55055a65b952e230c38aae4006ca252d3d934
treedf108ef00e2476ea4e39f3c5c2a7509dadddd596
parentc878fcf2ab5352b2311ca8846739937820352698
BUG/MINOR: lua: use strlcpy2() not strncpy() to copy sample keywords

The lua initialization code which creates the Lua mapping of all converters
and sample fetch keywords makes use of strncpy(), and as such can take ages
to start with large values of tune.bufsize because it spends its time zeroing
gigabytes of memory for nothing. A test performed with an extreme value of
16 MB takes roughly 4 seconds, so it's possible that some users with huge
1 MB buffers (e.g. for payload analysis) notice a small startup latency.
However this does not affect config checks since the Lua stack is not yet
started. Let's replace this with strlcpy2().

This should be backported to all supported versions.

(cherry picked from commit 5ef965606b5bacb12769c97f85b2cfd1c4e4ffe7)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit fa92f36beb65b4d0515892c783d40e94d33b131c)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/hlua.c