summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-08-22 15:20:16 +0100
committerSimon MacMullen <simon@rabbitmq.com>2014-08-22 15:20:16 +0100
commitf62bd1b57dd2b4ebdbab646dae6db7380a8c2d5d (patch)
tree0730348c422bcbdffe1a32fc013c95edd40ae5b1
parent79aeae4d15801b6f6742f3dcec4740b8feae2ff9 (diff)
downloadrabbitmq-server-f62bd1b57dd2b4ebdbab646dae6db7380a8c2d5d.tar.gz
We can't assume encoded lengths, so do it all in lists.
-rw-r--r--src/rabbit_channel.erl26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index 59453385..e5a90410 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -147,9 +147,13 @@ deliver(Pid, ConsumerTag, AckRequired, Msg) ->
gen_server2:cast(Pid, {deliver, ConsumerTag, AckRequired, Msg}).
deliver_reply(<<"amq.rabbitmq.reply-to.", Rest/binary>>, Delivery) ->
- {ok, Pid, Key} = decode_fast_reply_to(Rest),
- delegate:invoke_no_result(
- Pid, {?MODULE, deliver_reply_local, [Key, Delivery]}).
+ case decode_fast_reply_to(Rest) of
+ {ok, Pid, Key} ->
+ delegate:invoke_no_result(
+ Pid, {?MODULE, deliver_reply_local, [Key, Delivery]});
+ error ->
+ ok
+ end.
%% We want to ensure people can't use this mechanism to send a message
%% to an arbitrary process and kill it!
@@ -174,13 +178,12 @@ declare_fast_reply_to(<<"amq.rabbitmq.reply-to.", Rest/binary>>) ->
declare_fast_reply_to(_) ->
not_found.
-%% It's inelegant to depend on the encoded lengths here, but
-%% binary:split/2 does not exist in R13B03.
-decode_fast_reply_to(<<PidEnc:40/binary, ".", Key:24/binary>>) ->
- Pid = binary_to_term(base64:decode(PidEnc)),
- {ok, Pid, Key};
-decode_fast_reply_to(_) ->
- error.
+decode_fast_reply_to(Rest) ->
+ case string:tokens(binary_to_list(Rest), ".") of
+ [PidEnc, Key] -> Pid = binary_to_term(base64:decode(PidEnc)),
+ {ok, Pid, Key};
+ _ -> error
+ end.
send_credit_reply(Pid, Len) ->
gen_server2:cast(Pid, {send_credit_reply, Len}).
@@ -868,7 +871,8 @@ handle_method(#'basic.consume'{queue = <<"amq.rabbitmq.reply-to">>,
Key = base64:encode(rabbit_guid:gen_secure()),
PidEnc = base64:encode(term_to_binary(self())),
Suffix = <<PidEnc/binary, ".", Key/binary>>,
- State1 = State#ch{reply_consumer = {CTag, Suffix, Key}},
+ Consumer = {CTag, Suffix, binary_to_list(Key)},
+ State1 = State#ch{reply_consumer = Consumer},
case NoWait of
true -> {noreply, State1};
false -> Rep = #'basic.consume_ok'{consumer_tag = CTag},