fix: subscribe api crash with bad qos.

This commit is contained in:
zhongwencool 2022-03-21 09:19:28 +08:00
parent 479507b96a
commit 2be97a24dd
4 changed files with 5 additions and 1 deletions

View File

@ -48,6 +48,7 @@ File format:
* Prompt user how to change the dashboard's initial default password when emqx start.
* Fix errno=13 'Permission denied' Cannot create FIFO boot error in Amazon Linux 2022 (el8 package)
* Fix user or appid created, name only allow `^[A-Za-z]+[A-Za-z0-9-_]*$`
* Fix subscribe http api crash by bad_qos `/mqtt/subscribe`,`/mqtt/subscribe_batch`.
## v4.3.12
### Important changes

View File

@ -31,5 +31,6 @@
-define(ERROR13, 113). %% User already exist
-define(ERROR14, 114). %% OldPassword error
-define(ERROR15, 115). %% bad topic
-define(ERROR16, 116). %% bad QoS
-define(VERSIONS, ["4.0", "4.1", "4.2", "4.3"]).

View File

@ -1,6 +1,6 @@
{application, emqx_management,
[{description, "EMQ X Management API and CLI"},
{vsn, "4.3.12"}, % strict semver, bump manually!
{vsn, "4.3.13"}, % strict semver, bump manually!
{modules, []},
{registered, [emqx_management_sup]},
{applications, [kernel,stdlib,minirest]},

View File

@ -151,6 +151,8 @@ do_subscribe(ClientId, _Topics, _QoS) when not is_binary(ClientId) ->
{ok, ?ERROR8, <<"bad clientid: must be string">>};
do_subscribe(_ClientId, [], _QoS) ->
{ok, ?ERROR15, bad_topic};
do_subscribe(_ClientId, _Topic, QoS) when QoS =/= 0 andalso QoS =/= 1 andalso QoS =/= 2 ->
{ok, ?ERROR16, bad_qos};
do_subscribe(ClientId, Topics, QoS) ->
TopicTable = parse_topic_filters(Topics, QoS),
case emqx_mgmt:subscribe(ClientId, TopicTable) of