X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/305666bf59c50788fd31054e404d26df79ddf0c4..aef988258103ecded22b54d9a7132fd3d30ea565:/options.c diff --git a/options.c b/options.c index ea35841a..8a02d4f7 100644 --- a/options.c +++ b/options.c @@ -1490,17 +1490,16 @@ char *check_for_hostspec(char *s, char **host_ptr, int *port_ptr) if (*s == '[' && (p = strchr(s, ']')) != NULL) { s++; hostlen = p - s; - if (*p == ':') - *port_ptr = atoi(p+1); - else if (!*port_ptr) - *port_ptr = RSYNC_PORT; + if (p[1] == ':') + *port_ptr = atoi(p+2); } else { if ((p = strchr(s, ':')) != NULL) { hostlen = p - s; *port_ptr = atoi(p+1); - } else if (!*port_ptr) - *port_ptr = RSYNC_PORT; + } } + if (!*port_ptr) + *port_ptr = RSYNC_PORT; *host_ptr = new_array(char, hostlen + 1); strlcpy(*host_ptr, s, hostlen + 1); return path; @@ -1513,6 +1512,7 @@ char *check_for_hostspec(char *s, char **host_ptr, int *port_ptr) *p = ']'; if (not_host) return NULL; + p++; } else { if (!(p = strchr(s, ':'))) return NULL;