diff options
| author | Emile Joubert <emile@rabbitmq.com> | 2010-12-14 15:07:12 +0000 |
|---|---|---|
| committer | Emile Joubert <emile@rabbitmq.com> | 2010-12-14 15:07:12 +0000 |
| commit | 5f40f022bbfc23b16df506239d5fd427f4eca895 (patch) | |
| tree | 9391c6796b07876c4a509c293e789e31ed9d39e1 | |
| parent | 5d421ea6b12f84f77d2cf918952cad89186ec00f (diff) | |
| parent | 507d6336279278daf715e2c16427c308bc97ae9a (diff) | |
| download | rabbitmq-server-git-5f40f022bbfc23b16df506239d5fd427f4eca895.tar.gz | |
Merged bug23566 into default
| -rw-r--r-- | src/rabbit_auth_mechanism_plain.erl | 11 | ||||
| -rw-r--r-- | src/rabbit_reader.erl | 24 |
2 files changed, 20 insertions, 15 deletions
diff --git a/src/rabbit_auth_mechanism_plain.erl b/src/rabbit_auth_mechanism_plain.erl index 8758f85f6c..e5f8f3e6a1 100644 --- a/src/rabbit_auth_mechanism_plain.erl +++ b/src/rabbit_auth_mechanism_plain.erl @@ -56,6 +56,11 @@ init(_Sock) -> []. handle_response(Response, _State) -> - [User, Pass] = [list_to_binary(T) || - T <- string:tokens(binary_to_list(Response), [0])], - rabbit_access_control:check_user_pass_login(User, Pass). + %% The '%%"' at the end of the next line is for Emacs + case re:run(Response, "^\\0([^\\0]*)\\0([^\\0]*)$",%%" + [{capture, all_but_first, binary}]) of + {match, [User, Pass]} -> + rabbit_access_control:check_user_pass_login(User, Pass); + _ -> + {protocol_error, "response ~p invalid", [Response]} + end. diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl index 41b14771eb..92a2f4d7fe 100644 --- a/src/rabbit_reader.erl +++ b/src/rabbit_reader.erl @@ -714,24 +714,24 @@ ensure_stats_timer(State) -> handle_method0(MethodName, FieldsBin, State = #v1{connection = #connection{protocol = Protocol}}) -> - try - handle_method0(Protocol:decode_method_fields(MethodName, FieldsBin), - State) - catch exit:Reason -> - CompleteReason = case Reason of - #amqp_error{method = none} -> - Reason#amqp_error{method = MethodName}; - OtherReason -> OtherReason - end, + HandleException = + fun(R) -> case ?IS_RUNNING(State) of - true -> send_exception(State, 0, CompleteReason); + true -> send_exception(State, 0, R); %% We don't trust the client at this point - force %% them to wait for a bit so they can't DOS us with %% repeated failed logins etc. false -> timer:sleep(?SILENT_CLOSE_DELAY * 1000), - throw({channel0_error, State#v1.connection_state, - CompleteReason}) + throw({channel0_error, State#v1.connection_state, R}) end + end, + try + handle_method0(Protocol:decode_method_fields(MethodName, FieldsBin), + State) + catch exit:#amqp_error{method = none} = Reason -> + HandleException(Reason#amqp_error{method = MethodName}); + Type:Reason -> + HandleException({Type, Reason, MethodName, erlang:get_stacktrace()}) end. handle_method0(#'connection.start_ok'{mechanism = Mechanism, |
