]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: hlua_fcn: ensure Patref:add_bulk() is given a table object before using it
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 12 Jan 2026 16:23:27 +0000 (17:23 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Mon, 12 Jan 2026 16:30:54 +0000 (17:30 +0100)
As reported by GH user @kanashimia in GH #3241, providing anything else
than a table to Patref:add_bulk() method could cause a segfault because
we were calling lua_next() with the lua object without ensuring it
actually is a table.

Let's add the missing lua_istable() check on the stack object before
calling lua_next() function on it.

It should be backported up to 3.2 with 884dc62 ("MINOR: hlua_fcn:
add Patref:add_bulk()")

src/hlua_fcn.c

index 5026e30be159e9102ad7b8d3e80a64988f1541c0..6fc0d5d8bb4eafbd1a3f7dd3ecbab550d9b9cac4 100644 (file)
@@ -2796,6 +2796,11 @@ static int _hlua_patref_add_bulk(lua_State *L, int status, lua_KContext ctx)
        int count = 0;
        int ret;
 
+       if (!lua_istable(L, 2)) {
+               luaL_argerror(L, 2, "argument is expected to be a table");
+               return 0; // not reached
+       }
+
        if ((ref->flags & HLUA_PATREF_FL_GEN) &&
            pat_ref_may_commit(ref->ptr, ref->curr_gen))
                curr_gen = ref->curr_gen;