]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: lua: channel: append() must insert data at the end, not at the start
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 20 Nov 2026 16:23:57 +0000 (17:23 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 20 Nov 2026 16:28:20 +0000 (17:28 +0100)
hlua_channel_append() inserts the string at the offset of the start of the
input data, like hlua_channel_prepend() does, instead of after the existing
input data. The offset+len expression is computed and passed through
hlua_channel_filter() but never used. The function is otherwise identical to
hlua_channel_prepend(), it seems to be a copy-paste mistake when the
filter-aware insert path was introduced; hlua_http_msg_append() correctly
inserts at offset+len for the same operation.

As a result, Channel.append() behaved exactly like Channel.prepend(),
placing the string in front of the channel's input data instead of at its
end, in contradiction with its documentation ("Same as
Channel.insert(channel, string, channel:input())").

This patch should fix the issue #3598. It must be backported to all
supported versions.

src/hlua.c

index 51338956b24406df3a24dfde65a3fa1db02f7ebe..61545601e386dac8a724a6bee661f9149c105182 100644 (file)
@@ -4320,7 +4320,7 @@ __LJMP static int hlua_channel_append(lua_State *L)
        if (filter && !hlua_filter_from_payload(filter, chn))
                WILL_LJMP(lua_error(L));
 
-       ret = _hlua_channel_insert(chn, L, ist2(str, sz), offset);
+       ret = _hlua_channel_insert(chn, L, ist2(str, sz), offset+len);
        if (ret > 0 && filter) {
                struct hlua_flt_ctx *flt_ctx = filter->ctx;