Re: [PATCH 1/2] entry.c: convert checkout_entry to use strbuf

2013-10-23 Thread Jeff King
On Wed, Oct 23, 2013 at 11:09:27AM -0700, Junio C Hamano wrote: > > This is not something you introduced, but while we are here, you may > > want to use ce->namelen, which would be a little faster than treating it > > as a string (especially for strbuf, as it can then know up front how big > > the

Re: [PATCH 1/2] entry.c: convert checkout_entry to use strbuf

2013-10-23 Thread Junio C Hamano
Jeff King writes: > On Wed, Oct 23, 2013 at 07:55:06PM +0700, Nguyen Thai Ngoc Duy wrote: > ... >> -memcpy(path, state->base_dir, len); >> -strcpy(path + len, ce->name); >> -len += ce_namelen(ce); >> +strbuf_reset(&path_buf); >> +strbuf_addf(&path_buf, "%.*s%s", state->base_di

Re: [PATCH 1/2] entry.c: convert checkout_entry to use strbuf

2013-10-23 Thread Jeff King
On Wed, Oct 23, 2013 at 07:34:18PM +0200, Erik Faye-Lund wrote: > >> - memcpy(path, state->base_dir, len); > >> - strcpy(path + len, ce->name); > >> - len += ce_namelen(ce); > >> + strbuf_reset(&path_buf); > >> + strbuf_addf(&path_buf, "%.*s%s", state->base_dir_len, > >> state

Re: [PATCH 1/2] entry.c: convert checkout_entry to use strbuf

2013-10-23 Thread Erik Faye-Lund
On Wed, Oct 23, 2013 at 7:29 PM, Jeff King wrote: > On Wed, Oct 23, 2013 at 07:55:06PM +0700, Nguyen Thai Ngoc Duy wrote: > >> The old code does not do boundary check so any paths longer than >> PATH_MAX can cause buffer overflow. Replace it with strbuf to handle >> paths of arbitrary length. > >

Re: [PATCH 1/2] entry.c: convert checkout_entry to use strbuf

2013-10-23 Thread Jeff King
On Wed, Oct 23, 2013 at 07:55:06PM +0700, Nguyen Thai Ngoc Duy wrote: > The old code does not do boundary check so any paths longer than > PATH_MAX can cause buffer overflow. Replace it with strbuf to handle > paths of arbitrary length. I think this is a reasonable solution. If we have such a lon

Re: [PATCH 1/2] entry.c: convert checkout_entry to use strbuf

2013-10-23 Thread Antoine Pelisse
On Wed, Oct 23, 2013 at 3:04 PM, Duy Nguyen wrote: > On Wed, Oct 23, 2013 at 7:58 PM, Antoine Pelisse wrote: >>> diff --git a/entry.c b/entry.c >>> index acc892f..d955af5 100644 >>> --- a/entry.c >>> +++ b/entry.c >>> @@ -237,16 +237,18 @@ static int check_path(const char *path, int len, >>> str

Re: [PATCH 1/2] entry.c: convert checkout_entry to use strbuf

2013-10-23 Thread Duy Nguyen
On Wed, Oct 23, 2013 at 7:58 PM, Antoine Pelisse wrote: >> diff --git a/entry.c b/entry.c >> index acc892f..d955af5 100644 >> --- a/entry.c >> +++ b/entry.c >> @@ -237,16 +237,18 @@ static int check_path(const char *path, int len, >> struct stat *st, int skiplen) >> int checkout_entry(struct cac

Re: [PATCH 1/2] entry.c: convert checkout_entry to use strbuf

2013-10-23 Thread Antoine Pelisse
On Wed, Oct 23, 2013 at 2:55 PM, Nguyễn Thái Ngọc Duy wrote: > The old code does not do boundary check so any paths longer than > PATH_MAX can cause buffer overflow. Replace it with strbuf to handle > paths of arbitrary length. > > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > To get this topic go