mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
sha256: indirection for experimental functions
The experimental function signature is only available when `GIT_EXPERIMENTAL_SHA256` is enabled.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user