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

5 messages from 2008-03-06 to 2008-03-07. Participants: Pierre Habouzit, Junio C Hamano, Adeodato Simó.
Thread: https://gitlist.dev/t/12549

## Pierre Habouzit, 2008-03-06 21:28

Subject: [PATCH] unquote_c_style: fix off-by-one.
Message-ID: <20080306212819.GA10873@artemis.madism.org>
URL: https://gitlist.dev/e/20080306212819.GA10873%40artemis.madism.org

```
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(-)

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, 2008-03-06 22:10

Subject: Re: [PATCH] unquote_c_style: fix off-by-one.
Message-ID: <7vbq5ra4gu.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vbq5ra4gu.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <20080306212819.GA10873@artemis.madism.org>

```
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, 2008-03-07 00:44

Subject: Re: [PATCH] unquote_c_style: fix off-by-one.
Message-ID: <20080307004401.GA13642@artemis.madism.org>
URL: https://gitlist.dev/e/20080307004401.GA13642%40artemis.madism.org
In-Reply-To: <7vbq5ra4gu.fsf@gitster.siamese.dyndns.org>

```
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.

  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ó, 2008-03-07 09:25

Subject: Re: [PATCH] unquote_c_style: fix off-by-one.
Message-ID: <20080307092544.GA22069@chistera.yi.org>
URL: https://gitlist.dev/e/20080307092544.GA22069%40chistera.yi.org
In-Reply-To: <20080307004401.GA13642@artemis.madism.org>

```
* 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, 2008-03-07 21:28

Subject: Re: [PATCH] unquote_c_style: fix off-by-one.
Message-ID: <7vod9q1axe.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vod9q1axe.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <20080307092544.GA22069@chistera.yi.org>

```
Adeodato Simó <dato@net.com.org.es> writes:

> * 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.

```
