From 8d3d28f5dba94a15a79975e4adc909c295c80d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Fri, 27 Sep 2013 20:48:13 +0700 Subject: clone: tighten "local paths with colons" check a bit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 6000334 (clone: allow cloning local paths with colons in them - 2013-05-04) made it possible to specify a path that has colons in it without file://, e.g. ../foo:bar/somewhere. But the check was a bit sloppy. Consider the url '[foo]:bar'. The '[]' unwrapping code will turn the string to 'foo\0:bar'. In effect this new string is the same as 'foo/:bar' in the check "path < strchrnul(host, '/')", which mistakes it for a local path (with '/' before the first ':') when it's actually not. So disable the check for '/' before ':' when the URL has been mangled by '[]' unwrapping. [jn: with tests from Jeff King] Noticed-by: Morten Stenshorne Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Jonathan Nieder --- connect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'connect.c') diff --git a/connect.c b/connect.c index 715a309d2..3c6300a21 100644 --- a/connect.c +++ b/connect.c @@ -550,7 +550,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 */ -- cgit v1.2.1