diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2010-12-14 14:25:27 +0000 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2010-12-14 14:25:27 +0000 |
| commit | 9a88f0bdd5b566ad415a2311a83806b864de0ec0 (patch) | |
| tree | f41b26961673c81b8b0ba20f65e57c31974aab6b /src | |
| parent | dc71564903f1c123d847f560afb1009da24d027c (diff) | |
| parent | 2d1b014649cdba6507a14783820c45cfbc8dba9d (diff) | |
| download | rabbitmq-server-git-9a88f0bdd5b566ad415a2311a83806b864de0ec0.tar.gz | |
Merged from default
Diffstat (limited to 'src')
| -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..664a4ae90f 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); + _ -> + {refused, io_lib:format("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, |
