From d1ac732b8c08599a8b1b99e9ac63584ba078c895 Mon Sep 17 00:00:00 2001 From: Ery Lee Date: Wed, 14 Jan 2015 23:57:17 +0800 Subject: [PATCH] validate empty topics --- apps/emqtt/src/emqtt_protocol.erl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/emqtt/src/emqtt_protocol.erl b/apps/emqtt/src/emqtt_protocol.erl index a99f062fe..72e9813d4 100644 --- a/apps/emqtt/src/emqtt_protocol.erl +++ b/apps/emqtt/src/emqtt_protocol.erl @@ -381,6 +381,10 @@ validate_packet(#mqtt_packet{ header = #mqtt_packet_header { type = ?UNSUBSCRIB validate_packet(_Packet) -> ok. +validate_topics(Type, []) when Type =:= subscribe orelse Type =:= unsubscribe -> + lager:error("Empty Topics!"), + {error, empty_topics}; + validate_topics(Type, Topics) when Type =:= subscribe orelse Type =:= unsubscribe -> ErrTopics = [Topic || #mqtt_topic{name=Topic, qos=Qos} <- Topics, not (emqtt_topic:validate({Type, Topic}) and validate_qos(Qos))],