Commit ddbd3ab78e81b14070c26ba662eca38dafc6c16d

Con Kolivas 2013-09-07T09:14:12

Cope with trailing slashes in stratum urls.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/util.c b/util.c
index 5763dee..82de573 100644
--- a/util.c
+++ b/util.c
@@ -1107,9 +1107,14 @@ bool extract_sockaddr(char *url, char **sockaddr_url, char **sockaddr_port)
 
 	sprintf(url_address, "%.*s", url_len, url_begin);
 
-	if (port_len)
+	if (port_len) {
+		char *slash;
+
 		snprintf(port, 6, "%.*s", port_len, port_start);
-	else
+		slash = strchr(port, '/');
+		if (slash)
+			*slash = '\0';
+	} else
 		strcpy(port, "80");
 
 	*sockaddr_port = strdup(port);