Commit 31d8ad42 authored by Ian Craggs's avatar Ian Craggs

Merge branch 'develop' into mqttv5

parents 88225036 d27a7c58
......@@ -34,6 +34,7 @@
* Ian Craggs - auto reconnect timing fix #218
* Ian Craggs - fix for issue #190
* Ian Craggs - check for NULL SSL options #334
* Ian Craggs - allocate username/password buffers #431
* Ian Craggs - MQTT 5.0 support
*******************************************************************************/
......@@ -2439,14 +2440,22 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options)
}
#endif
m->c->username = options->username;
m->c->password = options->password;
if (m->c->username)
free((void*)m->c->username);
if (options->username)
m->c->username = MQTTStrdup(options->username);
if (m->c->password)
free((void*)m->c->password);
if (options->password)
{
m->c->password = MQTTStrdup(options->password);
m->c->passwordlen = strlen(options->password);
}
else if (options->struct_version >= 5 && options->binarypwd.data)
{
m->c->password = options->binarypwd.data;
m->c->passwordlen = options->binarypwd.len;
m->c->password = malloc(m->c->passwordlen);
memcpy((void*)m->c->password, options->binarypwd.data, m->c->passwordlen);
}
m->c->retryInterval = options->retryInterval;
......
......@@ -33,6 +33,7 @@
* Ian Craggs - binary will message support
* Ian Craggs - waitforCompletion fix #240
* Ian Craggs - check for NULL SSL options #334
* Ian Craggs - allocate username/password buffers #431
* Ian Craggs - MQTT 5.0 support
*******************************************************************************/
......@@ -1159,16 +1160,23 @@ static MQTTResponse MQTTClient_connectURI(MQTTClient handle, MQTTClient_connectO
}
#endif
m->c->username = options->username;
m->c->password = options->password;
if (m->c->username)
free((void*)m->c->username);
if (options->username)
m->c->username = MQTTStrdup(options->username);
if (m->c->password)
free((void*)m->c->password);
if (options->password)
{
m->c->password = MQTTStrdup(options->password);
m->c->passwordlen = strlen(options->password);
}
else if (options->struct_version >= 5 && options->binarypwd.data)
{
m->c->password = options->binarypwd.data;
m->c->passwordlen = options->binarypwd.len;
m->c->password = malloc(m->c->passwordlen);
memcpy((void*)m->c->password, options->binarypwd.data, m->c->passwordlen);
}
m->c->retryInterval = options->retryInterval;
if (options->struct_version >= 3)
MQTTVersion = options->MQTTVersion;
......
......@@ -681,6 +681,10 @@ void MQTTProtocol_freeClient(Clients* client)
free(client->will->topic);
free(client->will);
}
if (client->username)
free((void*)client->username);
if (client->password)
free((void*)client->password);
#if defined(OPENSSL)
if (client->sslopts)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment