From: Eric Sunshine Date: Sun, 01 Nov 2015 08:30:08 GMT Subject: Re: [PATCH] Limit the size of the data block passed to SHA1_Update() Message-ID: In-Reply-To: <1446359536-25829-1-git-send-email-apahlevan@ieee.org> On Sun, Nov 1, 2015 at 1:32 AM, wrote: > 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 > --- > 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? > +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 *'. > + 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