Skip to content

Commit

Permalink
unquote_c_style: fix off-by-one.
Browse files Browse the repository at this point in the history
The optional endp parameter to unquote_c_style() was supposed to point at
a location past the closing double quote, but it was going one beyond it.

git-fast-import used this function heavily and the bug caused it to
misparse the input stream, especially when parsing a rename command:

	R "filename that needs quoting" rename-target-name

Because the function erroneously ate the whitespace after the closing dq,
this triggered "Missing space after source" error when it shouldn't.

Thanks to Adeodato Simò for having caught this.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Pierre Habouzit authored and Junio C Hamano committed Mar 7, 2008
1 parent c2116a1 commit c8744d6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion quote.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ int unquote_c_style(struct strbuf *sb, const char *quoted, const char **endp)
switch (*quoted++) {
case '"':
if (endp)
*endp = quoted + 1;
*endp = quoted;
return 0;
case '\\':
break;
Expand Down

0 comments on commit c8744d6

Please sign in to comment.