Re: [PATCH 2/6] dir.c::match_basename(): pay attention to the length of string parameters
- From
Jeff King <peff@peff.net>
- Date
- Mar 29, 2013, 03:02 UTC
- Message-ID
- <20130329030217.GA1851@sigill.intra.peff.net>
- In-Reply-To
- <CACsJy8CcTqkPeOZ7Xa=7J4BH4sSFD6X6hKjrLz3kf0J0E_J+cw@mail.gmail.com>
On Fri, Mar 29, 2013 at 08:25:00AM +0700, Nguyen Thai Ngoc Duy wrote:
Show 23 quoted lines
> On Fri, Mar 29, 2013 at 4:47 AM, Jeff King <peff@peff.net> wrote:
> > +static int fnmatch_icase_mem(const char *pattern, int patternlen,
> > + const char *string, int stringlen,
> > + int flags)
> > +{
> > + int match_status;
> > + struct strbuf pat_buf = STRBUF_INIT;
> > + struct strbuf str_buf = STRBUF_INIT;
> > + const char *use_pat = pattern;
> > + const char *use_str = string;
> > +
> > + if (pattern[patternlen]) {
> > + strbuf_add(&pat_buf, pattern, patternlen);
> > + use_pat = pat_buf.buf;
> > + }
> > + if (string[stringlen]) {
> > + strbuf_add(&str_buf, string, stringlen);
> > + use_str = str_buf.buf;
> > + }
> > +
> > + match_status = fnmatch_icase(use_pat, use_str, 0);
>
> You should pass flags in here instead of 0.Eek, yeah, that's obviously wrong. Thanks for catching it. Fixing that clears up all of the test failures outside of t5002.
And if you move patch 5 ("special case paths that end with a slash") into position 2, it cleans up the mid-series failures of t5002, making the series clean for later bisecting.
Thanks for looking it over.
-Peff