From: Amaury Denoyelle Date: Thu, 29 Oct 2020 16:21:20 +0000 (+0100) Subject: BUG/MINOR: lua: initialize sample before using it X-Git-Tag: v2.3-dev9~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc0af6a19947c7ab76bd226beaaaafedc0648be4;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/hlua.c b/src/hlua.c index 9616a75186..97dcebd889 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. */