From bc0af6a19947c7ab76bd226beaaaafedc0648be4 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Thu, 29 Oct 2020 17:21:20 +0100 Subject: [PATCH] BUG/MINOR: lua: initialize sample before using it Memset the sample before using it through hlua_lua2smp. This function is ORing the smp.flags, so this field need to be cleared before its use. This was reported by a coverity warning. Fixes the github issue #929. This bug can be backported up to 1.8. --- src/hlua.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hlua.c b/src/hlua.c index 9616a7518..97dcebd88 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -3505,6 +3505,7 @@ __LJMP static int hlua_run_sample_conv(lua_State *L) } /* Initialise the sample. */ + memset(&smp, 0, sizeof(smp)); if (!hlua_lua2smp(L, 2, &smp)) { hlua_pusherror(L, "error in the input argument"); goto error; @@ -3649,6 +3650,7 @@ __LJMP static int hlua_applet_tcp_set_var(lua_State *L) s = appctx->htxn.s; /* Converts the third argument in a sample. */ + memset(&smp, 0, sizeof(smp)); hlua_lua2smp(L, 3, &smp); /* Store the sample in a variable. */ @@ -4133,6 +4135,7 @@ __LJMP static int hlua_applet_http_set_var(lua_State *L) s = appctx->htxn.s; /* Converts the third argument in a sample. */ + memset(&smp, 0, sizeof(smp)); hlua_lua2smp(L, 3, &smp); /* Store the sample in a variable. */ @@ -5225,6 +5228,7 @@ __LJMP static int hlua_set_var(lua_State *L) name = MAY_LJMP(luaL_checklstring(L, 2, &len)); /* Converts the third argument in a sample. */ + memset(&smp, 0, sizeof(smp)); hlua_lua2smp(L, 3, &smp); /* Store the sample in a variable. */