24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-14 22:00:16 +02:00

Malformed CAPTCHA response may crash a room. This is now fixed.

SVN Revision: 2148
This commit is contained in:
Evgeniy Khramtsov 2009-06-09 03:53:36 +00:00
parent 1266bf48e6
commit b7fd730409

View File

@ -153,22 +153,26 @@ process_reply({xmlelement, "captcha", _, _} = El) ->
{error, malformed}; {error, malformed};
Xdata -> Xdata ->
Fields = jlib:parse_xdata_submit(Xdata), Fields = jlib:parse_xdata_submit(Xdata),
[Id | _] = proplists:get_value("challenge", Fields, [none]), case {proplists:get_value("challenge", Fields),
[OCR | _] = proplists:get_value("ocr", Fields, [none]), proplists:get_value("ocr", Fields)} of
?T(case mnesia:read(captcha, Id, write) of {[Id|_], [OCR|_]} ->
[#captcha{pid=Pid, args=Args, key=Key, tref=Tref}] -> ?T(case mnesia:read(captcha, Id, write) of
mnesia:delete({captcha, Id}), [#captcha{pid=Pid, args=Args, key=Key, tref=Tref}] ->
erlang:cancel_timer(Tref), mnesia:delete({captcha, Id}),
if OCR == Key -> erlang:cancel_timer(Tref),
Pid ! {captcha_succeed, Args}, if OCR == Key ->
ok; Pid ! {captcha_succeed, Args},
true -> ok;
Pid ! {captcha_failed, Args}, true ->
{error, bad_match} Pid ! {captcha_failed, Args},
end; {error, bad_match}
_ -> end;
{error, not_found} _ ->
end) {error, not_found}
end);
_ ->
{error, malformed}
end
end; end;
process_reply(_) -> process_reply(_) ->
{error, malformed}. {error, malformed}.