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:
@@ -1675,6 +1675,7 @@ conf_apply_rules (lua_State *L)
|
|||||||
|
|
||||||
ap = wp_properties_new_empty ();
|
ap = wp_properties_new_empty ();
|
||||||
section = luaL_checkstring (L, 1);
|
section = luaL_checkstring (L, 1);
|
||||||
|
luaL_checktype (L, 2, LUA_TTABLE);
|
||||||
mp = wplua_table_to_properties (L, 2);
|
mp = wplua_table_to_properties (L, 2);
|
||||||
if (lua_isuserdata (L, 3)) {
|
if (lua_isuserdata (L, 3)) {
|
||||||
WpSpaJson *v = wplua_checkboxed (L, 3, WP_TYPE_SPA_JSON);
|
WpSpaJson *v = wplua_checkboxed (L, 3, WP_TYPE_SPA_JSON);
|
||||||
|
@@ -17,6 +17,11 @@ wplua_table_to_properties (lua_State *L, int idx)
|
|||||||
const gchar *key, *value;
|
const gchar *key, *value;
|
||||||
int table = lua_absindex (L, idx);
|
int table = lua_absindex (L, idx);
|
||||||
|
|
||||||
|
if (lua_type (L, table) != LUA_TTABLE) {
|
||||||
|
wp_critical ("skipping non-table value");
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
while (lua_next (L, table) != 0) {
|
while (lua_next (L, table) != 0) {
|
||||||
/* copy key & value to convert them to string */
|
/* copy key & value to convert them to string */
|
||||||
|
Reference in New Issue
Block a user