From: Junio C Hamano <gitster@pobox•com>
To: Andrew Wong <andrew.kw.w@gmail•com>
Cc: git@vger•kernel.org
Subject: Re: [PATCH] setup.c: Fix prefix_pathspec from looping pass end of string
Date: Thu, 07 Mar 2013 13:48:18 -0800 [thread overview]
Message-ID: <7vobeulw4d.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1362674163-24682-1-git-send-email-andrew.kw.w@gmail.com> (Andrew Wong's message of "Thu, 7 Mar 2013 11:36:03 -0500")
Andrew Wong <andrew.kw.w@gmail•com> writes:
> The previous code was assuming length ends at either `)` or `,`, and was
> not handling the case where strcspn returns length due to end of string.
> So specifying ":(top" as pathspec will cause the loop to go pass the end
> of string.
Thanks.
The parser that goes past the end of the string may be a bug worth
fixing, but is this patch sufficient to diagnose such an input as an
error?
> Signed-off-by: Andrew Wong <andrew.kw.w@gmail•com>
> ---
> setup.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/setup.c b/setup.c
> index 1dee47e..f4c4e73 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -207,9 +207,11 @@ static const char *prefix_pathspec(const char *prefix, int prefixlen, const char
> *copyfrom && *copyfrom != ')';
> copyfrom = nextat) {
> size_t len = strcspn(copyfrom, ",)");
> - if (copyfrom[len] == ')')
> + if (copyfrom[len] == '\0')
> nextat = copyfrom + len;
> - else
> + else if (copyfrom[len] == ')')
> + nextat = copyfrom + len;
> + else if (copyfrom[len] == ',')
> nextat = copyfrom + len + 1;
> if (!len)
> continue;
next prev parent reply other threads:[~2013-03-07 21:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-07 16:36 [PATCH] setup.c: Fix prefix_pathspec from looping pass end of string Andrew Wong
2013-03-07 21:48 ` Junio C Hamano [this message]
2013-03-07 22:25 ` Andrew Wong
2013-03-07 23:59 ` Junio C Hamano
2013-03-08 0:25 ` Andrew Wong
2013-03-08 1:51 ` Junio C Hamano
2013-03-08 1:58 ` Andrew Wong
2013-03-09 23:45 ` [PATCH 1/2] " Andrew Wong
2013-03-09 23:46 ` [PATCH 2/2] setup.c: Check that the pathspec magic ends with ")" Andrew Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vobeulw4d.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox$(echo .)com \
--cc=andrew.kw.w@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox