Re: [PATCH v2 2/3] Introduce a function to run regexec() on non-NUL-terminated buffers

2016-09-09 Thread Jeff King
On Fri, Sep 09, 2016 at 11:45:01AM +0200, Johannes Schindelin wrote: > > I mentioned elsewhere that I'd prefer we just push people into using > > compat/regex if they don't have REG_STARTEND. But if we _do_ keep this > > fallback, note that the above has a buffer overflow (think what happens > > w

Re: [PATCH v2 2/3] Introduce a function to run regexec() on non-NUL-terminated buffers

2016-09-09 Thread Johannes Schindelin
Hi Peff, On Thu, 8 Sep 2016, Jeff King wrote: > On Thu, Sep 08, 2016 at 09:31:11AM +0200, Johannes Schindelin wrote: > > > diff --git a/git-compat-util.h b/git-compat-util.h > > index db89ba7..19128b3 100644 > > --- a/git-compat-util.h > > +++ b/git-compat-util.h > > @@ -965,6 +965,27 @@ void gi

Re: [PATCH v2 2/3] Introduce a function to run regexec() on non-NUL-terminated buffers

2016-09-08 Thread Jeff King
On Thu, Sep 08, 2016 at 09:31:11AM +0200, Johannes Schindelin wrote: > diff --git a/git-compat-util.h b/git-compat-util.h > index db89ba7..19128b3 100644 > --- a/git-compat-util.h > +++ b/git-compat-util.h > @@ -965,6 +965,27 @@ void git_qsort(void *base, size_t nmemb, size_t size, > #define qsor

[PATCH v2 2/3] Introduce a function to run regexec() on non-NUL-terminated buffers

2016-09-08 Thread Johannes Schindelin
We just introduced a test that demonstrates that our sloppy use of regexec() on a mmap()ed area can result in incorrect results or even hard crashes. So what we need to fix this is a function that calls regexec() on a length-delimited, rather than a NUL-terminated, string. Happily, there is an ex