]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: lua: set buffer size during map lookups
authorThierry Fournier <thierry.fournier@ozon.io>
Tue, 10 Nov 2020 19:38:20 +0000 (20:38 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 11 Nov 2020 09:43:21 +0000 (10:43 +0100)
This size is used by some pattern matching to determine if there
is sufficient room in the buffer to add final \0 if necessary.
If the size is not set, the conditions use uninitialized value.

Note: it seems this bug can't cause a crash.

Should be backported until 2.2 (at least)

src/hlua.c

index 97dcebd889474996b102c7be48d6a4f84a05c2e7..f497892be454fdc069440934908892c2dd417e05 100644 (file)
@@ -1664,6 +1664,7 @@ __LJMP static inline int _hlua_map_lookup(struct lua_State *L, int str)
                smp.data.type = SMP_T_STR;
                smp.flags = SMP_F_CONST;
                smp.data.u.str.area = (char *)MAY_LJMP(luaL_checklstring(L, 2, (size_t *)&smp.data.u.str.data));
+               smp.data.u.str.size = smp.data.u.str.data + 1;
        }
 
        pat = pattern_exec_match(&desc->pat, &smp, 1);