{"thread":{"id":"27576","subject":"RE: [PATCH 3/3] verify_path: consider dos drive prefix","startedAt":"2011-06-08T09:55:08Z","lastAt":"2011-06-08T12:15:22Z","messageCount":4,"participants":["Theo Niessink","Erik Faye-Lund"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"169586","messageId":"DAFDEB13CE4944C18AAF3F20994AEF2E@martinic.local","threadId":"27576","inReplyTo":null,"subject":"RE: [PATCH 3/3] verify_path: consider dos drive prefix","fromName":"Theo Niessink","fromEmail":"niessink@martinic.com","sentAt":"2011-06-08T09:55:08Z","receivedAt":"2011-06-08T09:55:08Z","isPatch":true,"sender":{"key":"niessink@martinic.com","avatar":null},"body":"Junio C Hamano wrote:\n> Here is what I queued last night. If it looks Ok then I'll merge it down\n> to 'next'.\n\nI have run a couple of quick tests, and everything seems OK, except the\nfollowing backslashed paths, which are verified OK while they should be\nrejected:\n\nfoo\\.\\bar\nfoo\\..\\bar\n\nThis is caused by verify_dotfile(), which doesn't use is_dir_sep(). So I\npropose this patch on verify_dotfile():\n\ndiff --git a/read-cache.c b/read-cache.c\nindex 282c0c1..72be7cd 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -726,11 +726,12 @@ static int verify_dotfile(const char *rest)\n \t * has already been discarded, we now test\n \t * the rest.\n \t */\n-\tswitch (*rest) {\n+\n \t/* \".\" is not allowed */\n-\tcase '\\0': case '/':\n+\tif (*rest == '\\0' || is_dir_sep(*rest))\n \t\treturn 0;\n \n+\tswitch (*rest) {\n \t/*\n \t * \".git\" followed by  NUL or slash is bad. This\n \t * shares the path end test with the \"..\" case.\n@@ -743,7 +744,7 @@ static int verify_dotfile(const char *rest)\n \t\trest += 2;\n \t/* fallthrough */\n \tcase '.':\n-\t\tif (rest[1] == '\\0' || rest[1] == '/')\n+\t\tif (rest[1] == '\\0' || is_dir_sep(rest[1]))\n \t\t\treturn 0;\n \t}\n \treturn 1;\n"},{"id":"169592","messageId":"BANLkTinTJh9oOTHi5js7n-sy8+pmMa_vtQ@mail.gmail.com","threadId":"27576","inReplyTo":"DAFDEB13CE4944C18AAF3F20994AEF2E@martinic.local","subject":"Re: [PATCH 3/3] verify_path: consider dos drive prefix","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@gmail.com","sentAt":"2011-06-08T10:45:28Z","receivedAt":"2011-06-08T10:45:28Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Wed, Jun 8, 2011 at 11:55 AM, Theo Niessink <niessink@martinic.com> wrote:\n> Junio C Hamano wrote:\n>> Here is what I queued last night. If it looks Ok then I'll merge it down\n>> to 'next'.\n>\n> I have run a couple of quick tests, and everything seems OK, except the\n> following backslashed paths, which are verified OK while they should be\n> rejected:\n>\n> foo\\.\\bar\n> foo\\..\\bar\n>\n> This is caused by verify_dotfile(), which doesn't use is_dir_sep(). So I\n> propose this patch on verify_dotfile():\n>\n> diff --git a/read-cache.c b/read-cache.c\n> index 282c0c1..72be7cd 100644\n> --- a/read-cache.c\n> +++ b/read-cache.c\n> @@ -726,11 +726,12 @@ static int verify_dotfile(const char *rest)\n>         * has already been discarded, we now test\n>         * the rest.\n>         */\n> -       switch (*rest) {\n> +\n>        /* \".\" is not allowed */\n> -       case '\\0': case '/':\n> +       if (*rest == '\\0' || is_dir_sep(*rest))\n>                return 0;\n>\n> +       switch (*rest) {\n>        /*\n>         * \".git\" followed by  NUL or slash is bad. This\n>         * shares the path end test with the \"..\" case.\n> @@ -743,7 +744,7 @@ static int verify_dotfile(const char *rest)\n>                rest += 2;\n>        /* fallthrough */\n>        case '.':\n> -               if (rest[1] == '\\0' || rest[1] == '/')\n> +               if (rest[1] == '\\0' || is_dir_sep(rest[1]))\n>                        return 0;\n>        }\n>        return 1;\n>\n>\n>\n\nThis looks obviously correct to me. Thanks for spotting the problem.\n\nWould you mind writing up a commit-message and supply a sign-off?\n"},{"id":"169599","messageId":"187961B7EDE84635BD7B3C9A4EF688C3@martinic.local","threadId":"27576","inReplyTo":"BANLkTinTJh9oOTHi5js7n-sy8+pmMa_vtQ@mail.gmail.com","subject":"RE: [PATCH 3/3] verify_path: consider dos drive prefix","fromName":"Theo Niessink","fromEmail":"theo@taletn.com","sentAt":"2011-06-08T12:04:41Z","receivedAt":"2011-06-08T12:04:41Z","isPatch":true,"sender":{"key":"theo@taletn.com","avatar":"https://avatars.githubusercontent.com/u/5729397?v=4"},"body":"Erik Faye-Lund wrote:\n> This looks obviously correct to me. Thanks for spotting the problem.\n> \n> Would you mind writing up a commit-message and supply a sign-off?\n\nLike this you mean?\n\n-- >8 --\nSubject: [PATCH] verify_dotfile(): do not assume '/' is the path seperator\n\nverify_dotfile() currently assumes that the path seperator is '/', but on\nWindows it can also be '\\\\', so use is_dir_sep() instead.\n    \nSigned-off-by: Theo Niessink <theo@taletn.com>\n---\n read-cache.c |    7 ++++---\n 1 files changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/read-cache.c b/read-cache.c\nindex 282c0c1..72be7cd 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -726,11 +726,12 @@ static int verify_dotfile(const char *rest)\n \t * has already been discarded, we now test\n \t * the rest.\n \t */\n-\tswitch (*rest) {\n+\n \t/* \".\" is not allowed */\n-\tcase '\\0': case '/':\n+\tif (*rest == '\\0' || is_dir_sep(*rest))\n \t\treturn 0;\n \n+\tswitch (*rest) {\n \t/*\n \t * \".git\" followed by  NUL or slash is bad. This\n \t * shares the path end test with the \"..\" case.\n@@ -743,7 +744,7 @@ static int verify_dotfile(const char *rest)\n \t\trest += 2;\n \t/* fallthrough */\n \tcase '.':\n-\t\tif (rest[1] == '\\0' || rest[1] == '/')\n+\t\tif (rest[1] == '\\0' || is_dir_sep(rest[1]))\n \t\t\treturn 0;\n \t}\n \treturn 1;\n-- \n1.7.5.3776.g5dcaf.dirty\n"},{"id":"169600","messageId":"BANLkTik6mi002mWArJiLcC4rnvmotf5+2A@mail.gmail.com","threadId":"27576","inReplyTo":"187961B7EDE84635BD7B3C9A4EF688C3@martinic.local","subject":"Re: [PATCH 3/3] verify_path: consider dos drive prefix","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@gmail.com","sentAt":"2011-06-08T12:15:22Z","receivedAt":"2011-06-08T12:15:22Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Wed, Jun 8, 2011 at 2:04 PM, Theo Niessink <theo@taletn.com> wrote:\n> Erik Faye-Lund wrote:\n>> This looks obviously correct to me. Thanks for spotting the problem.\n>>\n>> Would you mind writing up a commit-message and supply a sign-off?\n>\n> Like this you mean?\n\nJust like that, indeed!\n\nJunio, what do you think, is this OK? I'd be great if we could have\nthis applied upstream, and then rebase-merge our branch on top for the\nnext Git for Windows release.\n"}]}