Skip to content

Commit

Permalink
Fix an infinite loop in sq_quote_buf().
Browse files Browse the repository at this point in the history
sq_quote_buf() treats single-quotes and exclamation marks specially, but
it incorrectly parsed the input for single-quotes and backslashes.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Johannes Sixt authored and Junio C Hamano committed Nov 4, 2007
1 parent 140dd77 commit c2015b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion quote.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void sq_quote_buf(struct strbuf *dst, const char *src)

strbuf_addch(dst, '\'');
while (*src) {
size_t len = strcspn(src, "'\\");
size_t len = strcspn(src, "'!");
strbuf_add(dst, src, len);
src += len;
while (need_bs_quote(*src)) {
Expand Down
7 changes: 7 additions & 0 deletions t/t5510-fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,11 @@ test_expect_success 'fetch with a non-applying branch.<name>.merge' '
git fetch blub
'

# the strange name is: a\!'b
test_expect_success 'quoting of a strangely named repo' '
! git fetch "a\\!'\''b" > result 2>&1 &&
cat result &&
grep "fatal: '\''a\\\\!'\''b'\''" result
'

test_done

0 comments on commit c2015b3

Please sign in to comment.