Bug #9073
closedlua/flowint: set() silently truncates 64-bit Lua integers to int
Description
- Status: present in
main(9b7938aec) - Class: silent integer truncation (semantics/robustness)
- Component:
src/util-lua-flowintlib.c:103(LuaFlowintSet)
Description¶
luaL_checkinteger yields a signed 64-bit lua_Integer; the cast truncates to int, and the value is stored in the uint32_t fv->data.fv_int.value. Examples: set(0x100000000) stores 0, set(-1) stores 4294967295, set(2^31) stores 2147483648, set(2^63-1) stores 4294967295 (GCC). Non-integral floats and strings already error via luaL_checkinteger.
Impact: packet-derived counters wrap silently; Lua flowint semantics diverge from the rule keyword's (detect-flowint.c), and value()/incr()/decr() operate on the truncated value. No memory unsafety.
Fix direction¶
Pick and document one semantic: reject values outside 0..UINT32_MAX with luaL_error, or make the storage/semantics 64-bit. Add a test that pins set(2^31), set(2^32), set(-1), set(2^63-1) and set(1.5).
Test¶
lua-flowint-bounds.
JI Updated by Jason Ish about 1 month ago
- Status changed from New to In Review
MR1382
JI Updated by Jason Ish about 1 month ago
- Assignee set to Victor Julien