forked from boostorg/mqtt5
Use properties by reference when validating them.
Reviewers: ivica Reviewed By: ivica Subscribers: korina Differential Revision: https://repo.mireo.local/D27963
This commit is contained in:
@ -123,14 +123,14 @@ public:
|
||||
|
||||
private:
|
||||
static error_code validate_disconnect(const disconnect_props& props) {
|
||||
auto reason_string = props[prop::reason_string];
|
||||
const auto& reason_string = props[prop::reason_string];
|
||||
if (
|
||||
reason_string &&
|
||||
validate_mqtt_utf8(*reason_string) != validation_result::valid
|
||||
)
|
||||
return client::error::malformed_packet;
|
||||
|
||||
auto user_properties = props[prop::user_property];
|
||||
const auto& user_properties = props[prop::user_property];
|
||||
for (const auto& user_property: user_properties)
|
||||
if (!is_valid_string_pair(user_property))
|
||||
return client::error::malformed_packet;
|
||||
|
@ -360,7 +360,7 @@ private:
|
||||
error_code validate_props(const publish_props& props) const {
|
||||
constexpr uint16_t default_topic_alias_max = 0;
|
||||
|
||||
auto topic_alias = props[prop::topic_alias];
|
||||
const auto& topic_alias = props[prop::topic_alias];
|
||||
if (topic_alias) {
|
||||
auto topic_alias_max = _svc_ptr->connack_property(prop::topic_alias_maximum)
|
||||
.value_or(default_topic_alias_max);
|
||||
@ -371,14 +371,14 @@ private:
|
||||
return client::error::malformed_packet;
|
||||
}
|
||||
|
||||
auto response_topic = props[prop::response_topic];
|
||||
const auto& response_topic = props[prop::response_topic];
|
||||
if (
|
||||
response_topic &&
|
||||
validate_topic_name(*response_topic) != validation_result::valid
|
||||
)
|
||||
return client::error::malformed_packet;
|
||||
|
||||
auto user_properties = props[prop::user_property];
|
||||
const auto& user_properties = props[prop::user_property];
|
||||
for (const auto& user_property: user_properties)
|
||||
if (!is_valid_string_pair(user_property))
|
||||
return client::error::malformed_packet;
|
||||
@ -386,7 +386,7 @@ private:
|
||||
if (!props[prop::subscription_identifier].empty())
|
||||
return client::error::malformed_packet;
|
||||
|
||||
auto content_type = props[prop::content_type];
|
||||
const auto& content_type = props[prop::content_type];
|
||||
if (
|
||||
content_type &&
|
||||
validate_mqtt_utf8(*content_type) != validation_result::valid
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
disconnect_rc_e::protocol_error
|
||||
);
|
||||
|
||||
const auto& [rc, auth_props] = auth_message;
|
||||
const auto& [rc, props] = auth_message;
|
||||
auto auth_rc = to_reason_code<reason_codes::category::auth>(rc);
|
||||
if (!auth_rc.has_value())
|
||||
return on_auth_fail(
|
||||
@ -70,7 +70,7 @@ public:
|
||||
disconnect_rc_e::malformed_packet
|
||||
);
|
||||
|
||||
auto server_auth_method = auth_props[prop::authentication_method];
|
||||
const auto& server_auth_method = props[prop::authentication_method];
|
||||
if (!server_auth_method || *server_auth_method != _auth.method())
|
||||
return on_auth_fail(
|
||||
"Malformed AUTH received: wrong authentication method",
|
||||
@ -79,7 +79,7 @@ public:
|
||||
|
||||
auto auth_step = auth_rc == reason_codes::success ?
|
||||
auth_step_e::server_final : auth_step_e::server_challenge;
|
||||
auto data = auth_props[prop::authentication_data].value_or("");
|
||||
auto data = props[prop::authentication_data].value_or("");
|
||||
|
||||
return _auth.async_auth(
|
||||
auth_step, std::move(data),
|
||||
|
@ -219,12 +219,12 @@ private:
|
||||
}
|
||||
|
||||
error_code validate_props(const subscribe_props& props) const {
|
||||
auto user_properties = props[prop::user_property];
|
||||
const auto& user_properties = props[prop::user_property];
|
||||
for (const auto& user_property: user_properties)
|
||||
if (!is_valid_string_pair(user_property))
|
||||
return client::error::malformed_packet;
|
||||
|
||||
auto sub_id = props[prop::subscription_identifier];
|
||||
const auto& sub_id = props[prop::subscription_identifier];
|
||||
if (!sub_id.has_value())
|
||||
return error_code {};
|
||||
|
||||
|
@ -177,7 +177,7 @@ private:
|
||||
if (validate_topic_filter(topic) != validation_result::valid)
|
||||
return client::error::invalid_topic;
|
||||
|
||||
auto user_properties = props[prop::user_property];
|
||||
const auto& user_properties = props[prop::user_property];
|
||||
for (const auto& user_property: user_properties)
|
||||
if (!is_valid_string_pair(user_property))
|
||||
return client::error::malformed_packet;
|
||||
|
Reference in New Issue
Block a user