m-lua-scripting: check argument type is table to avoid crashing

In conf_apply_rules, check input argument is a table before assuming it
is and potentially crashing.

Add check also in wplua_table_to_properties to avoid similar bugs.
This commit is contained in:
Pauli Virtanen
2023-10-13 22:35:41 +03:00
parent 4ad263b16c
commit b65f8884a5
2 changed files with 6 additions and 0 deletions

View File

@@ -1675,6 +1675,7 @@ conf_apply_rules (lua_State *L)
ap = wp_properties_new_empty ();
section = luaL_checkstring (L, 1);
luaL_checktype (L, 2, LUA_TTABLE);
mp = wplua_table_to_properties (L, 2);
if (lua_isuserdata (L, 3)) {
WpSpaJson *v = wplua_checkboxed (L, 3, WP_TYPE_SPA_JSON);

View File

@@ -17,6 +17,11 @@ wplua_table_to_properties (lua_State *L, int idx)
const gchar *key, *value;
int table = lua_absindex (L, idx);
if (lua_type (L, table) != LUA_TTABLE) {
wp_critical ("skipping non-table value");
return p;
}
lua_pushnil(L);
while (lua_next (L, table) != 0) {
/* copy key & value to convert them to string */