git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: [PATCH 3/3] verify_path: consider dos drive prefix
@ 2011-06-08  9:55 Theo Niessink
  2011-06-08 10:45 ` Erik Faye-Lund
  0 siblings, 1 reply; 16+ messages in thread
From: Theo Niessink @ 2011-06-08  9:55 UTC (permalink / raw)
  To: 'Junio C Hamano', kusmabite
  Cc: 'Johannes Sixt', git, johannes.schindelin

Junio C Hamano wrote:
> Here is what I queued last night. If it looks Ok then I'll merge it down
> to 'next'.

I have run a couple of quick tests, and everything seems OK, except the
following backslashed paths, which are verified OK while they should be
rejected:

foo\.\bar
foo\..\bar

This is caused by verify_dotfile(), which doesn't use is_dir_sep(). So I
propose this patch on verify_dotfile():

diff --git a/read-cache.c b/read-cache.c
index 282c0c1..72be7cd 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -726,11 +726,12 @@ static int verify_dotfile(const char *rest)
 	 * has already been discarded, we now test
 	 * the rest.
 	 */
-	switch (*rest) {
+
 	/* "." is not allowed */
-	case '\0': case '/':
+	if (*rest == '\0' || is_dir_sep(*rest))
 		return 0;
 
+	switch (*rest) {
 	/*
 	 * ".git" followed by  NUL or slash is bad. This
 	 * shares the path end test with the ".." case.
@@ -743,7 +744,7 @@ static int verify_dotfile(const char *rest)
 		rest += 2;
 	/* fallthrough */
 	case '.':
-		if (rest[1] == '\0' || rest[1] == '/')
+		if (rest[1] == '\0' || is_dir_sep(rest[1]))
 			return 0;
 	}
 	return 1;

^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [PATCH maint 0/3] do not write files outside of work-dir
@ 2011-05-27 16:00 Erik Faye-Lund
  2011-05-27 16:00 ` [PATCH 3/3] verify_path: consider dos drive prefix Erik Faye-Lund
  0 siblings, 1 reply; 16+ messages in thread
From: Erik Faye-Lund @ 2011-05-27 16:00 UTC (permalink / raw)
  To: git; +Cc: gitster, johannes.schindelin, j.sixt, Theo Niessink

Theo Niessink has uncovered a serious sercurity issue in Git for Windows,
where cloning an evil repository can arbitrarily overwrite files outside
the repository. Since many Windows users run as administrators, this can
be used for very nasty purposes.

The first two patches fix "git add" so it reject paths outside of the
repository when specified in the "C:\..."-form on Windows.

Patch 3/3 makes sure we don't try to actually write to these files.

This series applies cleanly to 'maint', and I strongly encourage that
we apply at the very least 3/3 there.

Erik Faye-Lund (1):
  verify_path: consider dos drive prefix

Theo Niessink (2):
  A Windows path starting with a backslash is absolute
  real_path: do not assume '/' is the path seperator

 abspath.c         |    4 ++--
 cache.h           |    2 +-
 compat/mingw.h    |    9 +++++++++
 git-compat-util.h |    4 ++++
 read-cache.c      |    5 ++++-
 5 files changed, 20 insertions(+), 4 deletions(-)

-- 
1.7.5.3.3.g435ff

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

end of thread, other threads:[~2011-06-08 12:16 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-08  9:55 [PATCH 3/3] verify_path: consider dos drive prefix Theo Niessink
2011-06-08 10:45 ` Erik Faye-Lund
2011-06-08 12:04   ` Theo Niessink
2011-06-08 12:15     ` Erik Faye-Lund
  -- strict thread matches above, loose matches on Subject: below --
2011-05-27 16:00 [PATCH maint 0/3] do not write files outside of work-dir Erik Faye-Lund
2011-05-27 16:00 ` [PATCH 3/3] verify_path: consider dos drive prefix Erik Faye-Lund
2011-05-27 18:58   ` Johannes Sixt
2011-05-30  9:32     ` Erik Faye-Lund
2011-05-30 10:58       ` Theo Niessink
2011-05-30 11:17         ` Erik Faye-Lund
2011-06-07  3:46           ` Junio C Hamano
2011-06-07 10:07             ` Erik Faye-Lund
2011-06-07 19:09               ` Erik Faye-Lund
2011-06-07 19:22                 ` Junio C Hamano
2011-06-07 19:32                   ` Erik Faye-Lund
2011-06-07 11:46             ` Theo Niessink
2011-05-30 20:23       ` Johannes Sixt

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).