diff options
author | David Rientjes <rientjes@google.com> | 2006-08-17 11:54:57 -0700 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-08-17 14:23:53 -0700 |
commit | a89fccd28197fa179828c8596791ff16e2268d20 (patch) | |
tree | 4a6c2b256a986fc221c0e1d5fa7d910f3b31eee8 /builtin-unpack-objects.c | |
parent | d4baf9eaf47ea1ba204f1ab5ecd22326913dd081 (diff) | |
download | git-a89fccd28197fa179828c8596791ff16e2268d20.tar.gz |
Do not use memcmp(sha1_1, sha1_2, 20) with hardcoded length.
Introduces global inline:
hashcmp(const unsigned char *sha1, const unsigned char *sha2)
Uses memcmp for comparison and returns the result based on the length of
the hash name (a future runtime decision).
Acked-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-unpack-objects.c')
-rw-r--r-- | builtin-unpack-objects.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c index 63f4b8e45d..f0ae5c987a 100644 --- a/builtin-unpack-objects.c +++ b/builtin-unpack-objects.c @@ -136,7 +136,7 @@ static void added_object(unsigned char *sha1, const char *type, void *data, unsi struct delta_info *info; while ((info = *p) != NULL) { - if (!memcmp(info->base_sha1, sha1, 20)) { + if (!hashcmp(info->base_sha1, sha1)) { *p = info->next; p = &delta_list; resolve_delta(type, data, size, info->delta, info->size); @@ -292,7 +292,7 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix) unpack_all(); SHA1_Update(&ctx, buffer, offset); SHA1_Final(sha1, &ctx); - if (memcmp(fill(20), sha1, 20)) + if (hashcmp(fill(20), sha1)) die("final sha1 did not match"); use(20); |