Re: [PATCH v2 2/2] sha1_file: use strncmp for string comparison

2014-06-30 Thread Jeff King
On Mon, Jun 30, 2014 at 06:35:50PM +0200, René Scharfe wrote: > > It's probably not a big deal, as we don't expect random > > junk in the pack directory, but I wonder if it would be better to be > > explicit, like: > > > > Here's a simpler approach: I agree that solves the problem. However, I'

Re: [PATCH v2 2/2] sha1_file: use strncmp for string comparison

2014-06-30 Thread Jeff King
On Mon, Jun 30, 2014 at 06:43:35PM +0200, René Scharfe wrote: > Am 30.06.2014 16:22, schrieb Jeff King: > >On Mon, Jun 30, 2014 at 08:59:53PM +0700, Duy Nguyen wrote: > > > >>On Mon, Jun 30, 2014 at 8:43 PM, Jeff King wrote: > diff --git a/sha1_file.c b/sha1_file.c > index 394fa45..8adab1

Re: [PATCH v2 2/2] sha1_file: use strncmp for string comparison

2014-06-30 Thread René Scharfe
Am 30.06.2014 16:22, schrieb Jeff King: On Mon, Jun 30, 2014 at 08:59:53PM +0700, Duy Nguyen wrote: On Mon, Jun 30, 2014 at 8:43 PM, Jeff King wrote: diff --git a/sha1_file.c b/sha1_file.c index 394fa45..8adab14 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1207,7 +1207,8 @@ static void prep

Re: [PATCH v2 2/2] sha1_file: use strncmp for string comparison

2014-06-30 Thread René Scharfe
Am 30.06.2014 15:43, schrieb Jeff King: > On Sun, Jun 29, 2014 at 07:56:25AM +0200, René Scharfe wrote: > >> Avoid overrunning the existing pack name (p->pack_name, a C string) in >> the case that the new path is longer by using strncmp instead of memcmp >> for comparing. While at it, replace the

Re: [PATCH v2 2/2] sha1_file: use strncmp for string comparison

2014-06-30 Thread Jeff King
On Mon, Jun 30, 2014 at 08:59:53PM +0700, Duy Nguyen wrote: > On Mon, Jun 30, 2014 at 8:43 PM, Jeff King wrote: > >> diff --git a/sha1_file.c b/sha1_file.c > >> index 394fa45..8adab14 100644 > >> --- a/sha1_file.c > >> +++ b/sha1_file.c > >> @@ -1207,7 +1207,8 @@ static void prepare_packed_git_on

Re: [PATCH v2 2/2] sha1_file: use strncmp for string comparison

2014-06-30 Thread Duy Nguyen
On Mon, Jun 30, 2014 at 8:43 PM, Jeff King wrote: >> diff --git a/sha1_file.c b/sha1_file.c >> index 394fa45..8adab14 100644 >> --- a/sha1_file.c >> +++ b/sha1_file.c >> @@ -1207,7 +1207,8 @@ static void prepare_packed_git_one(char *objdir, int >> local) >> if (has_extension(de->d_n

Re: [PATCH v2 2/2] sha1_file: use strncmp for string comparison

2014-06-30 Thread Jeff King
On Sun, Jun 29, 2014 at 07:56:25AM +0200, René Scharfe wrote: > Avoid overrunning the existing pack name (p->pack_name, a C string) in > the case that the new path is longer by using strncmp instead of memcmp > for comparing. While at it, replace the magic constant 4 with a > strlen call to docum

[PATCH v2 2/2] sha1_file: use strncmp for string comparison

2014-06-28 Thread René Scharfe
Avoid overrunning the existing pack name (p->pack_name, a C string) in the case that the new path is longer by using strncmp instead of memcmp for comparing. While at it, replace the magic constant 4 with a strlen call to document its meaning. Signed-off-by: Rene Scharfe --- No changes from inti