Re: [PATCH] Limit the size of the data block passed to SHA1_Update()
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Nov 1, 2015, 08:30 UTC
- Message-ID
- <CAPig+cSLoC-O1YneUVRjBpZzHLmASmRQx_+8b2dsk34ReU-ovw@mail.gmail.com>
- In-Reply-To
- <1446359536-25829-1-git-send-email-apahlevan@ieee.org>
On Sun, Nov 1, 2015 at 1:32 AM, <atousa.p@gmail.com> wrote:
Show 16 quoted lines
> Some implementations of SHA_Updates have inherent limits > on the max chunk size. SHA1_MAX_BLOCK_SIZE can be defined > to set the max chunk size supported, if required. This is > enabled for OSX CommonCrypto library and set to 1GiB. > > Signed-off-by: Atousa Pahlevan Duprat <apahlevan@ieee.org> > --- > diff --git a/compat/sha1_chunked.c b/compat/sha1_chunked.c > new file mode 100644 > index 0000000..bf62b1b > --- /dev/null > +++ b/compat/sha1_chunked.c > @@ -0,0 +1,21 @@ > +#include "cache.h" > + > +#ifdef SHA1_MAX_BLOCK_SIZE
This file is only compiled when SHA1_MAX_BLOCK_SIZE is defined, so does this #ifdef serve a purpose?
Show 5 quoted lines
> +int git_SHA1_Update(SHA_CTX *c, const void *data, size_t len)
> +{
> + size_t nr;
> + size_t total = 0;
> + char *cdata = (char*)data;Nit: This could be 'const char *'.
Show 12 quoted lines
> + while (len > 0) {
> + nr = len;
> + if (nr > SHA1_MAX_BLOCK_SIZE)
> + nr = SHA1_MAX_BLOCK_SIZE;
> + SHA1_Update(c, cdata, nr);
> + total += nr;
> + cdata += nr;
> + len -= nr;
> + }
> + return total;
> +}
> +#endif