commit 89a8666a0364791b8c6b40f914b1dc919592d1ee from: Stefan Sperling via: Thomas Adam date: Wed Sep 04 19:32:33 2024 UTC restore abort() calls in lib/hash.c In the spirit of commit b808e01085d775b284878dfeea5c06339a9f2ec2, restore the abort() call in got_hash_final_object_id() and add additional ones to cover other functions in this file. ok op@ commit - 0674467428bb864d0bbda6fd3275e0dcc86aad85 commit + 89a8666a0364791b8c6b40f914b1dc919592d1ee blob - d40e105145c22f33fe7cec5f0c4ec30ce0c7f502 blob + 40936929f879cc3b104cfb23f50f50ae7366d1b2 --- lib/hash.c +++ lib/hash.c @@ -198,6 +198,8 @@ got_hash_init(struct got_hash *hash, enum got_hash_alg SHA1Init(&hash->sha1_ctx); else if (algo == GOT_HASH_SHA256) SHA256Init(&hash->sha256_ctx); + else + abort(); } void @@ -207,6 +209,8 @@ got_hash_update(struct got_hash *hash, const void *dat SHA1Update(&hash->sha1_ctx, data, len); else if (hash->algo == GOT_HASH_SHA256) SHA256Update(&hash->sha256_ctx, data, len); + else + abort(); } void @@ -216,6 +220,8 @@ got_hash_final(struct got_hash *hash, uint8_t *out) SHA1Final(out, &hash->sha1_ctx); else if (hash->algo == GOT_HASH_SHA256) SHA256Final(out, &hash->sha256_ctx); + else + abort(); } void @@ -225,8 +231,10 @@ got_hash_final_object_id(struct got_hash *hash, struct id->algo = hash->algo; if (hash->algo == GOT_HASH_SHA1) SHA1Final(id->hash, &hash->sha1_ctx); - else + else if (hash->algo == GOT_HASH_SHA256) SHA256Final(id->hash, &hash->sha256_ctx); + else + abort(); } int @@ -236,5 +244,7 @@ got_hash_cmp(enum got_hash_algorithm algo, uint8_t *b1 return memcmp(b1, b2, SHA1_DIGEST_LENGTH); else if (algo == GOT_HASH_SHA256) return memcmp(b1, b2, SHA256_DIGEST_LENGTH); + else + abort(); return -1; }