git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clone: tighten "local paths with colons" check a bit
@ 2013-09-27 13:48 Nguyễn Thái Ngọc Duy
  2013-09-27 18:56 ` Jeff King
  2013-09-27 21:56 ` Jonathan Nieder
  0 siblings, 2 replies; 4+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2013-09-27 13:48 UTC (permalink / raw)
  To: git
  Cc: Jonathan Niedier, Morten Stenshorne,
	Nguyễn Thái Ngọc Duy

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 <mstensho@opera.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-09-28 13:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-27 13:48 [PATCH] clone: tighten "local paths with colons" check a bit Nguyễn Thái Ngọc Duy
2013-09-27 18:56 ` Jeff King
2013-09-27 21:56 ` Jonathan Nieder
2013-09-28 13:14   ` Torsten Bögershausen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).