Skip to content

Commit

Permalink
Fix CONNECT Control Packet marshaller
Browse files Browse the repository at this point in the history
Per to MQTT 3.1.1 Standard:
> If the User Name Flag is set to 0, the Password Flag MUST be set to 0 [MQTT-3.1.2-22].
  • Loading branch information
KonstantinRitt committed Aug 16, 2017
1 parent 2e5c64e commit 3385b07
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/mqtt/qmqtt_client_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,7 @@ void QMQTT::ClientPrivate::sendConnect()
if (!username().isEmpty())
{
flags = FLAG_USERNAME(flags, 1);
}
if (!password().isEmpty())
{
flags = FLAG_PASSWD(flags, 1);
flags = FLAG_PASSWD(flags, !password().isEmpty() ? 1 : 0);
}

//payload
Expand All @@ -231,10 +228,10 @@ void QMQTT::ClientPrivate::sendConnect()
if (!_username.isEmpty())
{
frame.writeString(_username);
}
if (!_password.isEmpty())
{
frame.writeString(_password);
if (!_password.isEmpty())
{
frame.writeString(_password);
}
}
_network->sendFrame(frame);
}
Expand Down

0 comments on commit 3385b07

Please sign in to comment.