Project

General

Profile

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

Added by Victor Julien 2 months ago. Updated 8 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
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:

return LuaGetStringArgument(luastate, lua_gettop(luastate));
Consequences:
  • tx:request_header("Host", "junk") looks up "junk" instead of "Host" (silently wrong key);
  • a detached call (local f = tx.request_header; f()) makes lua_gettop() == 0; lua_isstring(L, 0) is an invalid index - release builds read a stale/adjacent slot, LUA_USE_APICHECK builds 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.


Subtasks 1 (0 open — 1 closed)

Bug #9331: lua/http: LuaHttpGetHeader uses lua_gettop() as the argument index (8.0.x backport)ClosedVictor JulienActions

JI Updated by Jason Ish about 1 month ago Actions #1

  • Status changed from New to In Review

MR1382

JI Updated by Jason Ish about 1 month ago Actions #2

  • Assignee set to Victor Julien

JI Updated by Jason Ish 27 days ago Actions #3

  • Subtask #9331 added

JI Updated by Jason Ish 26 days ago Actions #4

  • Status changed from In Review to Closed

JI Updated by Jason Ish 8 days ago Actions #5

  • Private changed from Yes to No
Actions

Also available in: PDF Atom