aboutsummaryrefslogtreecommitdiffstats
path: root/options.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2009-01-28 23:17:46 -0800
committerWayne Davison <wayned@samba.org>2009-01-28 23:17:46 -0800
commit4d13a2fe559c038632fdf7ca60503e12b2be8485 (patch)
treeb0d3300ab9892227c06f4b453bd3246b4c760352 /options.c
parent58cf354711f9e7eb2ec2a54b5f623abb860dafcf (diff)
downloadandroid_external_rsync-4d13a2fe559c038632fdf7ca60503e12b2be8485.tar.gz
android_external_rsync-4d13a2fe559c038632fdf7ca60503e12b2be8485.tar.bz2
android_external_rsync-4d13a2fe559c038632fdf7ca60503e12b2be8485.zip
A few more improvements to the hostspec-parsing code.
Diffstat (limited to 'options.c')
-rw-r--r--options.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/options.c b/options.c
index 0c64eaa1..2f95992b 100644
--- a/options.c
+++ b/options.c
@@ -2626,17 +2626,18 @@ void server_options(char **args, int *argc_p)
* (required for parsing) [ and ] chars elided from the returned string. */
static char *parse_hostspec(char *str, char **path_start_ptr, int *port_ptr)
{
- char *s = str;
- char *host_start = str;
+ char *s, *host_start = str;
int hostlen = 0, userlen = 0;
char *ret;
- for ( ; ; s++) {
+ for (s = str; ; s++) {
if (!*s) {
/* It is only OK if we run out of string with rsync:// */
- if (port_ptr)
- break;
- return NULL;
+ if (!port_ptr)
+ return NULL;
+ if (!hostlen)
+ hostlen = s - host_start;
+ break;
}
if (*s == ':' || *s == '/') {
if (!hostlen)
@@ -2647,7 +2648,7 @@ static char *parse_hostspec(char *str, char **path_start_ptr, int *port_ptr)
} else if (port_ptr) {
*port_ptr = atoi(s);
while (isDigit(s)) s++;
- if (*s++ != '/')
+ if (*s && *s++ != '/')
return NULL;
}
break;