threads / patch / 12549

patchunquote_c_style: fix off-by-one.

Subject: [PATCH] unquote_c_style: fix off-by-one.

## tl;dr

5 messages between Mar 6, 2008 and Mar 7, 2008. Diffs are folded; open one to read it.

replies: 4people: 3as markdown or json

Pierre Habouzit· Mar 6, 2008, 21:28 UTC · lore
Thanks to Adeodato Simò for having caught this.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---
 quote.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to quote.c +1 −1
diff --git a/quote.c b/quote.c
index d061626..40702f6 100644
--- a/quote.c
+++ b/quote.c
@@ -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;
-- 
1.5.4.3.593.g07854
Junio C Hamano· Mar 6, 2008, 22:10 UTC · re: Pierre Habouzit · lore

Re: [PATCH] unquote_c_style: fix off-by-one.

Pierre Habouzit <madcoder@debian.org> writes:
> Thanks to Adeodato Simò for having caught this.
>
> Signed-off-by: Pierre Habouzit <madcoder@debian.org>

Thanks. I would have appreciated a comment that said something about what external breakages this one caused, so that we can have an entry in "bugs fixed" list.

A quick audit of the existing callers suggests that it is fast-import.
Pierre Habouzit· Mar 7, 2008, 00:44 UTC · re: Junio C Hamano · lore

Re: [PATCH] unquote_c_style: fix off-by-one.

On Thu, Mar 06, 2008 at 10:10:41PM +0000, Junio C Hamano wrote:
Show 11 quoted lines
> Pierre Habouzit <madcoder@debian.org> writes:
> 
> > Thanks to Adeodato Simò for having caught this.
> >
> > Signed-off-by: Pierre Habouzit <madcoder@debian.org>
> 
> Thanks.  I would have appreciated a comment that said something about what
> external breakages this one caused, so that we can have an entry in "bugs
> fixed" list.
> 
> A quick audit of the existing callers suggests that it is fast-import.
  I actually don't really know, Adeodato asked me to look into it
because I was the last that touched it, you have to ask him why he found
this :)
  I Cc'd him.
-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org
Adeodato Simó· Mar 7, 2008, 09:25 UTC · re: Pierre Habouzit · lore

Re: [PATCH] unquote_c_style: fix off-by-one.

* Pierre Habouzit [Fri, 07 Mar 2008 01:44:01 +0100]:
> On Thu, Mar 06, 2008 at 10:10:41PM +0000, Junio C Hamano wrote:
> > Pierre Habouzit <madcoder@debian.org> writes:
> > > Thanks to Adeodato Simò for having caught this.
> > > Signed-off-by: Pierre Habouzit <madcoder@debian.org>
> > Thanks.  I would have appreciated a comment that said something about what
> > external breakages this one caused, so that we can have an entry in "bugs
> > fixed" list.
> > A quick audit of the existing callers suggests that it is fast-import.

Yes, it's fast-import. In particular, trying to rename a file whose name contains spaces:

  R "file 1.txt" file 2.txt
                ^
                unquote_c_style() eats that space, thus fast-import
                fails with:
                fatal: Missing space after source: R "file 1.txt" file 2.txt
Cheers,
-- 
Adeodato Simó                                     dato at net.com.org.es
Debian Developer                                  adeodato at debian.org
 
- In Italy, for 30 years under the Borgias they had warfare, terror,
  murder, bloodshed, but they produced Michelangelo, Leonardo da Vinci,
  and the Renaissance. In Switzerland they had brotherly love - they had
  500 years of democracy and peace, and what did that produce? The
  cuckoo clock.
                -- Harry Lime in “The Third Man”
Junio C Hamano· Mar 7, 2008, 21:28 UTC · re: Adeodato Simó · lore

Re: [PATCH] unquote_c_style: fix off-by-one.

Adeodato Simó <dato@net.com.org.es> writes:
Show 25 quoted lines
> * Pierre Habouzit [Fri, 07 Mar 2008 01:44:01 +0100]:
>
>> On Thu, Mar 06, 2008 at 10:10:41PM +0000, Junio C Hamano wrote:
>> > Pierre Habouzit <madcoder@debian.org> writes:
>
>> > > Thanks to Adeodato Simò for having caught this.
>
>> > > Signed-off-by: Pierre Habouzit <madcoder@debian.org>
>
>> > Thanks.  I would have appreciated a comment that said something about what
>> > external breakages this one caused, so that we can have an entry in "bugs
>> > fixed" list.
>
>> > A quick audit of the existing callers suggests that it is fast-import.
>
> Yes, it's fast-import. In particular, trying to rename a file whose name
> contains spaces:
>
>   R "file 1.txt" file 2.txt
>                 ^
>                 unquote_c_style() eats that space, thus fast-import
>                 fails with:
>
>                 fatal: Missing space after source: R "file 1.txt" file 2.txt
>
Thanks.

← back to recent threads