]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: httpclient/lua: raise an error on too many request headers
authorMartin Mirchev <mirchevmartin2203@gmail.com>
Fri, 30 Oct 2026 05:49:13 +0000 (13:49 +0800)
committerWilliam Lallemand <wlallemand@irq6.net>
Tue, 3 Nov 2026 17:09:22 +0000 (18:09 +0100)
commita2175623a4bb0e050b100c105fe84435dc473211
treef0a768184bedffd04d0e6db3036be6f23660a3ae
parent0c31063873674bc3f7208b6370cc00311ea2f651
BUG/MINOR: httpclient/lua: raise an error on too many request headers

When a Lua httpclient request has more header values than
tune.http.maxhdr, hlua_httpclient_table_to_hdrs() pops the inner
lua_next() key and value and returns NULL. But the key and value of the
outer lua_next() loop on the headers table stay on the stack, so the
caller's lua_next() on the argument table gets the wrong key and the
request fails with a confusing error:

    runtime error: invalid key to 'next' from [C]: in method 'get'

The header values already duplicated with istdup() are also leaked.

Let's free them and raise an explicit Lua error instead, as the caller
does for the other invalid arguments:

    runtime error: too many headers (tune.http.maxhdr is 101)

The function is now marked __LJMP and its call wrapped in MAY_LJMP().

This should be backported where 2db801c63 ("BUG/MINOR: hlua: fix stack
overflow in httpclient headers conversion") was backported. Before 3.5
the function is in src/hlua.c.
src/http_client.c