Fix -L url parsing.

Closes #1248. Thanks to Andrew J Freyer.
This commit is contained in:
Roger A. Light 2019-04-29 23:43:52 +01:00
parent dc4b823f92
commit 203949a512
2 changed files with 9 additions and 4 deletions

View File

@ -8,11 +8,14 @@ Broker:
`response-topic`. Closes #1244. `response-topic`. Closes #1244.
- Fix build for WITH_TLS=no. Closes #1250. - Fix build for WITH_TLS=no. Closes #1250.
Client library: Library:
- Fix crash after client has been unable to connect to a broker. This occurs - Fix crash after client has been unable to connect to a broker. This occurs
when the client is exiting and is part of the final library cleanup routine. when the client is exiting and is part of the final library cleanup routine.
Closes #1246. Closes #1246.
Clients:
- Fix -L url parsing. Closes #1248.
1.6.1 - 20190426 1.6.1 - 20190426
================ ================

View File

@ -669,13 +669,13 @@ int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int argc, c
tmp = strchr(url, '@'); tmp = strchr(url, '@');
if(tmp) { if(tmp) {
char *colon = strchr(url, ':');
*tmp++ = 0; *tmp++ = 0;
char *colon = strchr(url, ':');
if(colon) { if(colon) {
*colon = 0; *colon = 0;
cfg->password = colon + 1; cfg->password = strdup(colon + 1);
} }
cfg->username = url; cfg->username = strdup(url);
url = tmp; url = tmp;
} }
cfg->host = url; cfg->host = url;
@ -685,6 +685,8 @@ int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int argc, c
*tmp++ = 0; *tmp++ = 0;
cfg->port = atoi(tmp); cfg->port = atoi(tmp);
} }
/* Now we've removed the port, time to get the host on the heap */
cfg->host = strdup(cfg->host);
} }
i++; i++;
}else if(!strcmp(argv[i], "-l") || !strcmp(argv[i], "--stdin-line")){ }else if(!strcmp(argv[i], "-l") || !strcmp(argv[i], "--stdin-line")){