Commit 151b321898a4b24bfa25f0c4a6bacf6565e0cdb4

Ben Straub 2013-10-31T13:16:04

Prevent segfault with a badly-formed URL

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/src/netops.c b/src/netops.c
index 7a61ef8..5f0db24 100644
--- a/src/netops.c
+++ b/src/netops.c
@@ -679,9 +679,10 @@ int gitno_extract_url_parts(
 	slash = strchr(url, '/');
 	at = strchr(url, '@');
 
-	if (slash == NULL) {
-		giterr_set(GITERR_NET, "Malformed URL: missing /");
-		return -1;
+	if (!slash ||
+	    (colon && slash < colon)) {
+		giterr_set(GITERR_NET, "Malformed URL");
+		return GIT_EINVALIDSPEC;
 	}
 
 	start = url;