summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2010-12-14 14:25:27 +0000
committerSimon MacMullen <simon@rabbitmq.com>2010-12-14 14:25:27 +0000
commitf6798f3cdbf210e96ad11364a014e5ccf0e01008 (patch)
treef41b26961673c81b8b0ba20f65e57c31974aab6b
parentd0d38f8bed2f8f5d5a3949040fcb14dd1837f4e2 (diff)
parent26a2a8af60013a80acd011fe99982e152b150991 (diff)
downloadrabbitmq-server-f6798f3cdbf210e96ad11364a014e5ccf0e01008.tar.gz
Merged from default
-rw-r--r--src/rabbit_auth_mechanism_plain.erl11
-rw-r--r--src/rabbit_reader.erl24
2 files changed, 20 insertions, 15 deletions
diff --git a/src/rabbit_auth_mechanism_plain.erl b/src/rabbit_auth_mechanism_plain.erl
index 8758f85f..664a4ae9 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 41b14771..92a2f4d7 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,