Actions
Bug #9081
closed
VJ
VJ
lua/http: LuaHttpGetHeader uses lua_gettop() as the argument index
Bug #9081:
lua/http: LuaHttpGetHeader uses lua_gettop() as the argument index
Affected Versions:
Effort:
Difficulty:
Label:
Description
- Status: present in
main(9b7938aec); code-confirmed - Class: API/argument-index bug (wrong or invalid stack index)
- Component:
src/util-lua-http.c:151-155(LuaHttpGetHeader)
Description¶
The header-name argument is read with a lua_gettop()-relative index instead of the fixed argument index:
tx:request_header("Host", "junk")looks up"junk"instead of"Host"(silently wrong key);- a detached call (
local f = tx.request_header; f()) makeslua_gettop() == 0;lua_isstring(L, 0)is an invalid index - release builds read a stale/adjacent slot,LUA_USE_APICHECKbuilds abort; - any variadic wrapper forwarding extra values changes the lookup key.
Fix direction¶
Use the fixed index 2 (LuaGetStringArgument(luastate, 2)).
Test¶
lua-http-header-arg-index: extra-arg, zero-arg and numeric-arg calls; assert deterministic nil/error and run one pass under a DebugValidation/APICHECK build.
Actions