summaryrefslogtreecommitdiff
path: root/http-fetch.c
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2006-08-17 18:54:57 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-08-17 21:23:53 (GMT)
commita89fccd28197fa179828c8596791ff16e2268d20 (patch)
tree4a6c2b256a986fc221c0e1d5fa7d910f3b31eee8 /http-fetch.c
parentd4baf9eaf47ea1ba204f1ab5ecd22326913dd081 (diff)
downloadgit-a89fccd28197fa179828c8596791ff16e2268d20.zip
git-a89fccd28197fa179828c8596791ff16e2268d20.tar.gz
git-a89fccd28197fa179828c8596791ff16e2268d20.tar.bz2
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 'http-fetch.c')
-rw-r--r--http-fetch.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/http-fetch.c b/http-fetch.c
index 7f07d2a..d1f74b4 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -301,7 +301,7 @@ static void finish_object_request(struct object_request *obj_req)
unlink(obj_req->tmpfile);
return;
}
- if (memcmp(obj_req->sha1, obj_req->real_sha1, 20)) {
+ if (hashcmp(obj_req->sha1, obj_req->real_sha1)) {
unlink(obj_req->tmpfile);
return;
}
@@ -1070,7 +1070,7 @@ static int fetch_object(struct alt_base *repo, unsigned char *sha1)
int ret = 0;
struct object_request *obj_req = object_queue_head;
- while (obj_req != NULL && memcmp(obj_req->sha1, sha1, 20))
+ while (obj_req != NULL && hashcmp(obj_req->sha1, sha1))
obj_req = obj_req->next;
if (obj_req == NULL)
return error("Couldn't find request for %s in the queue", hex);
@@ -1109,7 +1109,7 @@ static int fetch_object(struct alt_base *repo, unsigned char *sha1)
} else if (obj_req->zret != Z_STREAM_END) {
corrupt_object_found++;
ret = error("File %s (%s) corrupt", hex, obj_req->url);
- } else if (memcmp(obj_req->sha1, obj_req->real_sha1, 20)) {
+ } else if (hashcmp(obj_req->sha1, obj_req->real_sha1)) {
ret = error("File %s has bad hash", hex);
} else if (obj_req->rename < 0) {
ret = error("unable to write sha1 filename %s",