BUG/MINOR: hlua: fix uninitialized var in hlua_core_get_var()
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 24 Jan 2024 15:10:55 +0000 (16:10 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 31 Jan 2024 14:44:56 +0000 (15:44 +0100)
commit7eaf2342bbed7784353d3ddb3dba3b5714850273
tree2484632d0c3882745f889937ac6572e47f552d4b
parent79ab2bc2a498c76b7fe43fe37d6dabd827f1ca50
BUG/MINOR: hlua: fix uninitialized var in hlua_core_get_var()

As raised by Coverity in GH #2223, f034139bc0 ("MINOR: lua: Allow reading
"proc." scoped vars from LUA core.") causes uninitialized reads due to
smp being passed to vars_get_by_name() without being initialized first.

Indeed, vars_get_by_name() tries to read smp->sess and smp->strm pointers.
As we're only interested in the PROC var scope, it is safe to call
vars_get_by_name() with sess and strm pointers set to NULL, thus we
simply memset smp prior to calling vars_get_by_name() to fix the issue.

This should be backported in 2.9 with f034139bc0.

(cherry picked from commit 564addcb727bfb3dd46507ec824f11c20c6bb861)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/hlua.c