{"thread":{"id":"10652","subject":"[PATCH] Fix an infinite loop in sq_quote_buf().","startedAt":"2007-11-04T20:26:22Z","lastAt":"2007-11-04T21:37:59Z","messageCount":2,"participants":["Johannes Sixt","Pierre Habouzit"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"58303","messageId":"200711042126.22512.johannes.sixt@telecom.at","threadId":"10652","inReplyTo":null,"subject":"[PATCH] Fix an infinite loop in sq_quote_buf().","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-11-04T20:26:22Z","receivedAt":"2007-11-04T20:26:22Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"sq_quote_buf() treats single-quotes and exclamation marks specially, but\nit incorrectly parsed the input for single-quotes and backslashes.\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n quote.c          |    2 +-\n t/t5510-fetch.sh |    7 +++++++\n 2 files changed, 8 insertions(+), 1 deletions(-)\n\ndiff --git a/quote.c b/quote.c\nindex 482be05..919d092 100644\n--- a/quote.c\n+++ b/quote.c\n@@ -26,7 +26,7 @@ void sq_quote_buf(struct strbuf *dst, const char *src)\n \n \tstrbuf_addch(dst, '\\'');\n \twhile (*src) {\n-\t\tsize_t len = strcspn(src, \"'\\\\\");\n+\t\tsize_t len = strcspn(src, \"'!\");\n \t\tstrbuf_add(dst, src, len);\n \t\tsrc += len;\n \t\twhile (need_bs_quote(*src)) {\ndiff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh\nindex d217657..aad863d 100755\n--- a/t/t5510-fetch.sh\n+++ b/t/t5510-fetch.sh\n@@ -208,4 +208,11 @@ test_expect_success 'fetch with a non-applying branch.<name>.merge' '\n \tgit fetch blub\n '\n \n+# the strange name is: a\\!'b\n+test_expect_success 'quoting of a strangely named repo' '\n+\t! git fetch \"a\\\\!'\\''b\" > result 2>&1 &&\n+\tcat result &&\n+\tgrep \"fatal: '\\''a\\\\\\\\!'\\''b'\\''\" result\n+'\n+\n test_done\n-- \n1.5.3.4.315.g2ce38\n"},{"id":"58311","messageId":"20071104213759.GD4207@artemis.corp","threadId":"10652","inReplyTo":"200711042126.22512.johannes.sixt@telecom.at","subject":"Re: [PATCH] Fix an infinite loop in sq_quote_buf().","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-04T21:37:59Z","receivedAt":"2007-11-04T21:37:59Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Sun, Nov 04, 2007 at 08:26:22PM +0000, Johannes Sixt wrote:\n> sq_quote_buf() treats single-quotes and exclamation marks specially, but\n> it incorrectly parsed the input for single-quotes and backslashes.\n> \n> Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n> ---\n>  quote.c          |    2 +-\n>  t/t5510-fetch.sh |    7 +++++++\n>  2 files changed, 8 insertions(+), 1 deletions(-)\n> \n> diff --git a/quote.c b/quote.c\n> index 482be05..919d092 100644\n> --- a/quote.c\n> +++ b/quote.c\n> @@ -26,7 +26,7 @@ void sq_quote_buf(struct strbuf *dst, const char *src)\n>  \n>  \tstrbuf_addch(dst, '\\'');\n>  \twhile (*src) {\n> -\t\tsize_t len = strcspn(src, \"'\\\\\");\n> +\t\tsize_t len = strcspn(src, \"'!\");\n>  \t\tstrbuf_add(dst, src, len);\n>  \t\tsrc += len;\n>  \t\twhile (need_bs_quote(*src)) {\n\n  Ouch, good catch :/ sorry about that.\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"}]}