Project

General

Profile

Actions

Bug #9084

closed
VJ VJ

lua: enable_hassh()/enable_ja3() return 1 without pushing a value

Bug #9084: lua: enable_hassh()/enable_ja3() return 1 without pushing a value

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: C-function stack-contract bug (wrong return value)
  • Component: src/util-lua-ssh.c:178-182 (enable_hassh), src/util-lua-ja3.c:183-186 (enable_ja3)

Description

Both functions end with return 1 without pushing a value:

static int LuaSshEnableHassh(lua_State *L)
{
    SCSshEnableHassh();
    return 1;
}

Lua takes the result from L->top - 1, so the script receives the last argument or, when called with no arguments, the function object itself. Under LUA_USE_APICHECK the return-count check (api_checknelems) aborts.

Trigger: local r = ssh.enable_hassh() / assert(ssh.enable_hassh()) / the same for ja3.enable_ja3() from any state (rule, transform, output).

Fix direction

return 0; (or push a boolean/nil and return 1). Document that both are process-global, parse-time switches that only affect flows parsed afterwards.

Test

lua-ssh-enable-hassh-return / lua-ja3-enable-return: assert the return value is nil, from init and from an output setup.


Subtasks 1 (0 open — 1 closed)

Bug #9334: lua: enable_hassh()/enable_ja3() return 1 without pushing a value (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 #9334 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