Commit 04a7b562 authored by Ian Craggs's avatar Ian Craggs

Actual fix for issue #179

parent 54957bdd
......@@ -19,6 +19,7 @@
* Ian Craggs - fix for bug 479376
* Ian Craggs - SNI support
* Ian Craggs - fix for issue #164
* Ian Craggs - fix for issue #179
*******************************************************************************/
/**
......@@ -57,7 +58,7 @@ char* MQTTProtocol_addressPort(const char* uri, int* port)
colon_pos = NULL; /* means it was an IPv6 separator, not for host:port */
}
if (colon_pos)
if (colon_pos) /* have to strip off the port */
{
size_t addr_len = colon_pos - uri;
buf = malloc(addr_len + 1);
......@@ -69,8 +70,15 @@ char* MQTTProtocol_addressPort(const char* uri, int* port)
len = strlen(buf);
if (buf[len - 1] == ']')
{
if (buf == (char*)uri)
{
buf = malloc(len); /* we are stripping off the final ], so length is 1 shorter */
MQTTStrncpy(buf, uri, len);
}
else
buf[len - 1] = '\0';
}
FUNC_EXIT;
return buf;
}
......
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