Thread (4 messages) flat view 4 messages, 4 authors, 2016-06-15
STALE3737d

[PATCH] clone: tighten "local paths with colons" check a bit

From: Nguyễn Thái Ngọc Duy <hidden>
Date: 2016-06-15 22:58:54
Subsystem: the rest · Maintainer: Linus Torvalds

commit 6000334 (clone: allow cloning local paths with colons in them -
2013-05-04) is added to make it possible to specify a path that has
colons in it without file://, e.g. ../foo:bar/somewhere. But the check
is a bit loose.

Consider the url '[foo]:bar', the '[]' unwrapping code will turn the
string to 'foo\0:bar'. The effect of this new string is the same as
'foo/:bar' to the expression "path < strchrnul(host, '/')", which
mistakes it as a sign of local paths while it's actually not.

Make sure we only check so when no protocol is specified and the url
is not started with '['.

Noticed-by: Morten Stenshorne [off-list ref]
Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
 I wanted to add a test then realized there were no ssh tests in the
 test suite. So laziness won :p

 connect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/connect.c b/connect.c
index a0783d4..303f850 100644
--- a/connect.c
+++ b/connect.c
@@ -551,7 +551,7 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
 	path = strchr(end, c);
 	if (path && !has_dos_drive_prefix(end)) {
 		if (c == ':') {
-			if (path < strchrnul(host, '/')) {
+			if (host != url || path < strchrnul(host, '/')) {
 				protocol = PROTO_SSH;
 				*path++ = '\0';
 			} else /* '/' in the host part, assume local path */
-- 
1.8.2.83.gc99314b
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help