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 /sha1_name.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 'sha1_name.c')
-rw-r--r-- | sha1_name.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sha1_name.c b/sha1_name.c index f567454d22..e9eb6ce882 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -84,7 +84,7 @@ static int find_short_packed_object(int len, const unsigned char *match, unsigne int cmp; nth_packed_object_sha1(p, mid, now); - cmp = memcmp(match, now, 20); + cmp = hashcmp(match, now); if (!cmp) { first = mid; break; @@ -106,7 +106,7 @@ static int find_short_packed_object(int len, const unsigned char *match, unsigne memcpy(found_sha1, now, 20); found++; } - else if (memcmp(found_sha1, now, 20)) { + else if (hashcmp(found_sha1, now)) { found = 2; break; } @@ -144,7 +144,7 @@ static int find_unique_short_object(int len, char *canonical, return 0; } /* Both have unique ones -- do they match? */ - if (memcmp(packed_sha1, unpacked_sha1, 20)) + if (hashcmp(packed_sha1, unpacked_sha1)) return SHORT_NAME_AMBIGUOUS; memcpy(sha1, packed_sha1, 20); return 0; |