Merge branch 'ad/sha1-update-chunked' into maint
Apple's common crypto implementation of SHA1_Update() does not take more than 4GB at a time, and we now have a compile-time workaround for it. * ad/sha1-update-chunked: sha1: allow limiting the size of the data passed to SHA1_Update() sha1: provide another level of indirection for the SHA-1 functions
This commit is contained in:
@ -16,6 +16,10 @@
|
||||
#undef TYPE_BOOL
|
||||
#endif
|
||||
|
||||
#ifndef SHA1_MAX_BLOCK_SIZE
|
||||
#error Using Apple Common Crypto library requires setting SHA1_MAX_BLOCK_SIZE
|
||||
#endif
|
||||
|
||||
#ifdef APPLE_LION_OR_NEWER
|
||||
#define git_CC_error_check(pattern, err) \
|
||||
do { \
|
||||
|
||||
19
compat/sha1-chunked.c
Normal file
19
compat/sha1-chunked.c
Normal file
@ -0,0 +1,19 @@
|
||||
#include "cache.h"
|
||||
|
||||
int git_SHA1_Update_Chunked(platform_SHA_CTX *c, const void *data, size_t len)
|
||||
{
|
||||
size_t nr;
|
||||
size_t total = 0;
|
||||
const char *cdata = (const char*)data;
|
||||
|
||||
while (len) {
|
||||
nr = len;
|
||||
if (nr > SHA1_MAX_BLOCK_SIZE)
|
||||
nr = SHA1_MAX_BLOCK_SIZE;
|
||||
platform_SHA1_Update(c, cdata, nr);
|
||||
total += nr;
|
||||
cdata += nr;
|
||||
len -= nr;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
2
compat/sha1-chunked.h
Normal file
2
compat/sha1-chunked.h
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
int git_SHA1_Update_Chunked(platform_SHA_CTX *c, const void *data, size_t len);
|
||||
Reference in New Issue
Block a user