]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: hlua: Don't rely on top of the stack when using Lua buffers
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 3 May 2021 08:11:13 +0000 (10:11 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 3 May 2021 08:34:48 +0000 (10:34 +0200)
commitc31b2008728babbc8738b88b593f2be40324369b
tree0d86f2b6f605ba7c05eddbf7b94ef58c6a843997
parent080347fe2a47c649ee5d420fc4e60385229cb642
BUG/MINOR: hlua: Don't rely on top of the stack when using Lua buffers

When the lua buffers are used, a variable number of stack slots may be
used. Thus we cannot assume that we know where the top of the stack is. It
was not an issue for lua < 5.4.3 (at least for small buffers). But
'socket:receive()' now fails with lua 5.4.3 because a light userdata is
systematically pushed on the top of the stack when a buffer is initialized.

To fix the bug, in hlua_socket_receive(), we save the index of the top of
the stack before creating the buffer. This way, we can check the number of
arguments, regardless anything was pushed on the stack or not.

Note that the other buffer usages seem to be safe.

This patch should solve the issue #1240. It should be backport to all stable
branches.
src/hlua.c