Re: [PATCH 56/67] avoid sprintf and strcpy with flex arrays

2015-09-21 Thread Jeff King
On Mon, Sep 21, 2015 at 01:11:09PM -0400, Eric Sunshine wrote: > >> > - p = xcalloc(1, sizeof(*p) + strlen(tmp_file) + 2); > >> > - strcpy(p->pack_name, tmp_file); > >> > + namelen = strlen(tmp_file) + 2; > >> > >> You mentioned this specially in the commit message, but from a br

Re: [PATCH 56/67] avoid sprintf and strcpy with flex arrays

2015-09-21 Thread Eric Sunshine
On Mon, Sep 21, 2015 at 11:15 AM, Jeff King wrote: > On Sun, Sep 20, 2015 at 06:48:32PM -0400, Eric Sunshine wrote: >> > diff --git a/archive.c b/archive.c >> > index 01b0899..4ac86c8 100644 >> > --- a/archive.c >> > +++ b/archive.c >> > @@ -171,13 +171,14 @@ static void queue_directory(const unsi

Re: [PATCH 56/67] avoid sprintf and strcpy with flex arrays

2015-09-21 Thread Jeff King
On Sun, Sep 20, 2015 at 06:48:32PM -0400, Eric Sunshine wrote: > > diff --git a/archive.c b/archive.c > > index 01b0899..4ac86c8 100644 > > --- a/archive.c > > +++ b/archive.c > > @@ -171,13 +171,14 @@ static void queue_directory(const unsigned char *sha1, > > unsigned mode, int st

Re: [PATCH 56/67] avoid sprintf and strcpy with flex arrays

2015-09-20 Thread Eric Sunshine
On Tue, Sep 15, 2015 at 12:09 PM, Jeff King wrote: > When we are allocating a struct with a FLEX_ARRAY member, we > generally compute the size of the array and then sprintf or > strcpy into it. Normally we could improve a dynamic allocation > like this by using xstrfmt, but it doesn't work here; w

[PATCH 56/67] avoid sprintf and strcpy with flex arrays

2015-09-15 Thread Jeff King
When we are allocating a struct with a FLEX_ARRAY member, we generally compute the size of the array and then sprintf or strcpy into it. Normally we could improve a dynamic allocation like this by using xstrfmt, but it doesn't work here; we have to account for the size of the rest of the struct. B