commit b94703ce28d8c088927b2412ca63592c10dc3b37 from: Omar Polo date: Sat Feb 04 14:00:31 2023 UTC fix got_object_id_cmp for sha256 commit - cf67c0d95b97d5a74575e1061be649435bd88489 commit + b94703ce28d8c088927b2412ca63592c10dc3b37 blob - 294a0d3507c5fa97bca600bd2835cdaf5257d91f blob + 0e0092a04fcb2d9a40bcfacc9cfbd86fc7d919cb --- lib/object_parse.c +++ lib/object_parse.c @@ -72,7 +72,14 @@ int got_object_id_cmp(const struct got_object_id *id1, const struct got_object_id *id2) { - return memcmp(id1->hash, id2->hash, SHA1_DIGEST_LENGTH); + if (id1->algo != id2->algo) + return -1; + + if (id1->algo == GOT_HASH_SHA256) + return memcmp(id1->hash, id2->hash, SHA256_DIGEST_LENGTH); + if (id1->algo == GOT_HASH_SHA1) + return memcmp(id1->hash, id2->hash, SHA1_DIGEST_LENGTH); + return -1; } const struct got_error *