Skip to content

Commit

Permalink
Fix parsing of malformed socks urls.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed Nov 17, 2014
1 parent 166bc2c commit 41f5d1f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions client/client_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,10 @@ static int mosquitto__parse_socks_url(struct mosq_config *cfg, char *url)
if(have_auth){
/* Have already seen a @ , so this must be of form
* socks5h://username[:password]@host:port */
if(host){
/* Already seen a host, must be malformed. */
goto cleanup;
}
len = i-start;
host = malloc(len + 1);
memcpy(host, &(str[start]), len);
Expand Down Expand Up @@ -849,6 +853,10 @@ static int mosquitto__parse_socks_url(struct mosq_config *cfg, char *url)
}else{
/* Haven't seen a : yet, so must be of form
* socks5h://username@... */
if(username){
/* Already got a username, must be malformed. */
goto cleanup;
}
len = i-start;
username = malloc(len + 1);
memcpy(username, &(str[start]), len);
Expand Down

0 comments on commit 41f5d1f

Please sign in to comment.