BUG/MINOR: hlua: Fix Channel:data() and Channel:line() to respect documentation
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 12 May 2025 14:12:13 +0000 (16:12 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 20 May 2025 16:11:47 +0000 (18:11 +0200)
commit8e42802fe755b534debdc5099a8497ea92986ed5
tree10d39c9813b3ef6fb9c0941e97bfdf252b34a749
parent5c9e7032da8e70d2f30ac804f40c9ddb20249143
BUG/MINOR: hlua: Fix Channel:data() and Channel:line() to respect documentation

When the channel API was revisted, the both functions above was added. An
offset can be passed as argument. However, this parameter could be reported
to be out of range if there was not enough input data was received yet. It
is an issue, especially with a tcp rule, because more data could be
received. If an error is reported too early, this prevent the rule to be
reevaluated later. In fact, an error should only be reported if the offset
is part of the output data.

Another issue is about the conditions to report 'nil' instead of an empty
string. 'nil' was reported when no data was found. But it is not aligned
with the documentation. 'nil' must only be returned if no more data cannot
be received and there is no input data at all.

This patch should fix the issue #2716. It should be backported as far as 2.6.

(cherry picked from commit a5de0e15959a241afc9afb39f1b02a2517894f7b)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit ab8b159b39983e969510bc4b5902984d80f18f62)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/hlua.c