From 0447ab4be23e77c1120444ef463125061bd7de58 Mon Sep 17 00:00:00 2001 From: Peter Jakobs Date: Mon, 28 Oct 2024 11:15:17 +0100 Subject: [PATCH] Catch situations where mqttClient::connect is called with an empty clientName. --- Sming/Components/Network/src/Network/Mqtt/MqttClient.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sming/Components/Network/src/Network/Mqtt/MqttClient.cpp b/Sming/Components/Network/src/Network/Mqtt/MqttClient.cpp index be7e8896a7..0d9bd1bc7b 100644 --- a/Sming/Components/Network/src/Network/Mqtt/MqttClient.cpp +++ b/Sming/Components/Network/src/Network/Mqtt/MqttClient.cpp @@ -199,11 +199,16 @@ bool MqttClient::setWill(const String& topic, const String& message, uint8_t fla bool MqttClient::connect(const Url& url, const String& clientName) { this->url = url; + bool useSsl{url.Scheme == URI_SCHEME_MQTT_SECURE}; if(!useSsl && url.Scheme != URI_SCHEME_MQTT) { debug_e("Only mqtt and mqtts protocols are allowed"); return false; } + if(clientName == "") { + debug_e("clientName cannot be empty"); + return false; + } if(getConnectionState() != eTCS_Ready) { close();