Skip to content

Commit

Permalink
catch situations where mqttClient::connect is called with an empty cl…
Browse files Browse the repository at this point in the history
…ientName that would otherwise lead to a failing malloc
  • Loading branch information
pljakobs committed Oct 25, 2024
1 parent 2c08c85 commit 50547d4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sming/Components/Network/src/Network/Mqtt/MqttClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,17 @@ 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("no client name configured");
return false;
}


if(getConnectionState() != eTCS_Ready) {
close();
Expand Down

0 comments on commit 50547d4

Please sign in to comment.