diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-12-08 14:05:03 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-12-08 14:05:03 -0800 |
commit | b5d2d8eef0ad08022a3f635c0bc292eb2cc5aefc (patch) | |
tree | 591e520fa223ef9294eb0fe50b7868023f3262a3 /compat | |
parent | e6ed5a438c7a5436a08c08e269174d9975f8dc1d (diff) | |
parent | 001fd7a90b5851f62e700510729a5e09706f9b63 (diff) | |
download | git-b5d2d8eef0ad08022a3f635c0bc292eb2cc5aefc.tar.gz git-b5d2d8eef0ad08022a3f635c0bc292eb2cc5aefc.tar.xz |
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
Diffstat (limited to 'compat')
-rw-r--r-- | compat/apple-common-crypto.h | 4 | ||||
-rw-r--r-- | compat/sha1-chunked.c | 19 | ||||
-rw-r--r-- | compat/sha1-chunked.h | 2 |
3 files changed, 25 insertions, 0 deletions
diff --git a/compat/apple-common-crypto.h b/compat/apple-common-crypto.h index c8b9b0e1a..d3fb26418 100644 --- a/compat/apple-common-crypto.h +++ b/compat/apple-common-crypto.h @@ -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 { \ diff --git a/compat/sha1-chunked.c b/compat/sha1-chunked.c new file mode 100644 index 000000000..6adfcfd54 --- /dev/null +++ b/compat/sha1-chunked.c @@ -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; +} diff --git a/compat/sha1-chunked.h b/compat/sha1-chunked.h new file mode 100644 index 000000000..7b2df28ee --- /dev/null +++ b/compat/sha1-chunked.h @@ -0,0 +1,2 @@ + +int git_SHA1_Update_Chunked(platform_SHA_CTX *c, const void *data, size_t len); |