]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: hlua: fix optional timeout argument index for AppletTCP:receive()
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 18 Mar 2025 13:22:00 +0000 (14:22 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Tue, 18 Mar 2025 15:48:32 +0000 (16:48 +0100)
commit4651c4edd5c32ffd5a2244147b3b7bff20accd5f
tree9c5cf5da953974bb0aed853c6a68adb5db9a8d16
parentc880c32b16dfd633aa7a8290b74dd46fc4f004cb
BUG/MINOR: hlua: fix optional timeout argument index for AppletTCP:receive()

Baptiste reported that using the new optional timeout argument introduced
in 19e48f2 ("MINOR: hlua: add an optional timeout to AppletTCP:receive()")
the following error would occur at some point:

runtime error: file.lua:lineno: bad argument #-2 to 'receive' (number
expected, got light userdata) from [C]: in method 'receive...

In fact this is caused by exp_date being retrieved using relative index -1
instead of absolute index 3. Indeed, while using relative index is fine
most of the time when we trust the stack, when combined with yielding the
top of the stack when resuming from yielding is not necessarily the same
as when the function was first called (ie: if some data was pushed to the
stack in the yieldable function itself). As such, it is safer to use
explicit index to access exp_date variable at position 3 on the stack.

It was confirmed that doing so addresses the issue.

No backport needed unless 19e48f2 is.
src/hlua.c