sha256: indirection for experimental functions

The experimental function signature is only available when
`GIT_EXPERIMENTAL_SHA256` is enabled.
This commit is contained in:
Edward Thomson
2022-07-13 22:25:11 -04:00
parent 433a133402
commit b43567d655
188 changed files with 1211 additions and 957 deletions

View File

@@ -36,10 +36,19 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
fprintf(stderr, "Failed to limit maximum pack object count\n");
abort();
}
#ifdef GIT_EXPERIMENTAL_SHA256
if (git_odb_new(&odb, NULL) < 0) {
fprintf(stderr, "Failed to create the odb\n");
abort();
}
#else
if (git_odb_new(&odb) < 0) {
fprintf(stderr, "Failed to create the odb\n");
abort();
}
#endif
if (git_mempack_new(&mempack) < 0) {
fprintf(stderr, "Failed to create the mempack\n");
abort();
@@ -90,10 +99,18 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
if (git_indexer_append(indexer, data, size, &stats) < 0)
goto cleanup;
if (append_hash) {
#ifdef GIT_EXPERIMENTAL_SHA256
if (git_odb_hash(&oid, data, size, GIT_OBJECT_BLOB, GIT_OID_SHA1) < 0) {
fprintf(stderr, "Failed to compute the SHA1 hash\n");
abort();
}
#else
if (git_odb_hash(&oid, data, size, GIT_OBJECT_BLOB) < 0) {
fprintf(stderr, "Failed to compute the SHA1 hash\n");
abort();
}
#endif
if (git_indexer_append(indexer, &oid.id, GIT_OID_SHA1_SIZE, &stats) < 0) {
goto cleanup;
}