]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: lua: initialize sample before using it
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 29 Oct 2020 16:21:20 +0000 (17:21 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 29 Oct 2020 17:52:44 +0000 (18:52 +0100)
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

index 9616a75186cb4463b5d24da1182c2525d6583390..97dcebd889474996b102c7be48d6a4f84a05c2e7 100644 (file)
@@ -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. */