25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Don't crash on malformed 'modules' section

This commit is contained in:
Evgeny Khramtsov 2019-02-19 12:31:18 +03:00
parent b30775a357
commit 8def827f9c
2 changed files with 16 additions and 6 deletions

View File

@ -713,10 +713,16 @@ process_term(Term, State) ->
process_host_term(Term, Host, State, Action) ->
case Term of
{modules, Modules} when Action == set ->
set_option({modules, Host}, replace_modules(Modules), State);
{modules, Modules} when Action == append ->
append_option({modules, Host}, replace_modules(Modules), State);
{modules, Modules} ->
Modules1 = try (gen_mod:opt_type(modules))(Modules) of
_ -> replace_modules(Modules)
catch _:_ -> Modules
end,
if Action == set ->
set_option({modules, Host}, Modules1, State);
Action == append ->
append_option({modules, Host}, Modules1, State)
end;
{host, _} ->
State;
{hosts, _} ->

View File

@ -937,8 +937,12 @@ opt_type(modules) ->
fun(Mods) ->
lists:map(
fun({M, A}) when is_atom(M) ->
true = is_opt_list(A),
{M, A}
case is_opt_list(A) of
true -> {M, A};
false ->
?ERROR_MSG("Malformed configuration format of module ~s", [M]),
erlang:error(badarg)
end
end, Mods)
end;
opt_type(_) -> [modules].