summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2010-10-15 11:41:22 +0100
committerMatthew Sackman <matthew@rabbitmq.com>2010-10-15 11:41:22 +0100
commit3b2fb31d009e56c7a57a7d3e7a78cc27ebb6ff0c (patch)
treeef1826d314c532dcea5e9a3b23bfe6894242db1d
parentbb031efbe162e845d49b3fb305af777130d142d2 (diff)
downloadrabbitmq-server-bug23405.tar.gz
Prevent expansion of routing key if binding destination is an exchangebug23405
-rw-r--r--src/rabbit_channel.erl16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index d11b0684..5ddb2337 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -368,6 +368,13 @@ expand_routing_key_shortcut(<<>>, <<>>,
expand_routing_key_shortcut(_QueueNameBin, RoutingKey, _State) ->
RoutingKey.
+expand_binding(queue, DestinationNameBin, RoutingKey, State) ->
+ {expand_queue_name_shortcut(DestinationNameBin, State),
+ expand_routing_key_shortcut(DestinationNameBin, RoutingKey, State)};
+expand_binding(exchange, DestinationNameBin, RoutingKey, State) ->
+ {rabbit_misc:r(State#ch.virtual_host, exchange, DestinationNameBin),
+ RoutingKey}.
+
%% check that an exchange/queue name does not contain the reserved
%% "amq." prefix.
%%
@@ -919,14 +926,9 @@ binding_action(Fun, ExchangeNameBin, DestinationType, DestinationNameBin,
%% (see rule named "failure" in spec-XML)
%% FIXME: don't allow binding to internal exchanges -
%% including the one named "" !
- DestinationName =
- case DestinationType of
- queue -> expand_queue_name_shortcut(DestinationNameBin, State);
- exchange -> rabbit_misc:r(VHostPath, exchange, DestinationNameBin)
- end,
+ {DestinationName, ActualRoutingKey} =
+ expand_binding(DestinationType, DestinationNameBin, RoutingKey, State),
check_write_permitted(DestinationName, State),
- ActualRoutingKey =
- expand_routing_key_shortcut(DestinationNameBin, RoutingKey, State),
ExchangeName = rabbit_misc:r(VHostPath, exchange, ExchangeNameBin),
check_read_permitted(ExchangeName, State),
case Fun(#binding{source = ExchangeName,