diff options
Diffstat (limited to 'fuzzers')
-rw-r--r-- | fuzzers/commit_graph_fuzzer.c | 14 | ||||
-rw-r--r-- | fuzzers/midx_fuzzer.c | 11 | ||||
-rw-r--r-- | fuzzers/packfile_fuzzer.c | 16 | ||||
-rw-r--r-- | fuzzers/standalone_driver.c | 4 |
4 files changed, 22 insertions, 23 deletions
diff --git a/fuzzers/commit_graph_fuzzer.c b/fuzzers/commit_graph_fuzzer.c index 39b520882..05783a259 100644 --- a/fuzzers/commit_graph_fuzzer.c +++ b/fuzzers/commit_graph_fuzzer.c @@ -11,8 +11,8 @@ #include "git2.h" -#include "buffer.h" #include "common.h" +#include "str.h" #include "futils.h" #include "hash.h" #include "commit_graph.h" @@ -33,7 +33,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { git_commit_graph_file file = {{0}}; git_commit_graph_entry e; - git_buf commit_graph_buf = GIT_BUF_INIT; + git_str commit_graph_buf = GIT_STR_INIT; unsigned char hash[GIT_HASH_SHA1_SIZE]; git_oid oid = {{0}}; bool append_hash = false; @@ -51,7 +51,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) size -= 4; if (append_hash) { - if (git_buf_init(&commit_graph_buf, size + GIT_HASH_SHA1_SIZE) < 0) + if (git_str_init(&commit_graph_buf, size + GIT_HASH_SHA1_SIZE) < 0) goto cleanup; if (git_hash_buf(hash, data, size, GIT_HASH_ALGORITHM_SHA1) < 0) { fprintf(stderr, "Failed to compute the SHA1 hash\n"); @@ -62,13 +62,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) memcpy(oid.id, hash, GIT_OID_RAWSZ); } else { - git_buf_attach_notowned(&commit_graph_buf, (char *)data, size); + git_str_attach_notowned(&commit_graph_buf, (char *)data, size); } if (git_commit_graph_file_parse( &file, - (const unsigned char *)git_buf_cstr(&commit_graph_buf), - git_buf_len(&commit_graph_buf)) + (const unsigned char *)git_str_cstr(&commit_graph_buf), + git_str_len(&commit_graph_buf)) < 0) goto cleanup; @@ -78,6 +78,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) cleanup: git_commit_graph_file_close(&file); - git_buf_dispose(&commit_graph_buf); + git_str_dispose(&commit_graph_buf); return 0; } diff --git a/fuzzers/midx_fuzzer.c b/fuzzers/midx_fuzzer.c index 9739f0a40..3cd609063 100644 --- a/fuzzers/midx_fuzzer.c +++ b/fuzzers/midx_fuzzer.c @@ -11,7 +11,6 @@ #include "git2.h" -#include "buffer.h" #include "common.h" #include "futils.h" #include "hash.h" @@ -33,7 +32,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { git_midx_file idx = {{0}}; git_midx_entry e; - git_buf midx_buf = GIT_BUF_INIT; + git_str midx_buf = GIT_STR_INIT; unsigned char hash[GIT_HASH_SHA1_SIZE]; git_oid oid = {{0}}; bool append_hash = false; @@ -51,7 +50,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) size -= 4; if (append_hash) { - if (git_buf_init(&midx_buf, size + GIT_HASH_SHA1_SIZE) < 0) + if (git_str_init(&midx_buf, size + GIT_HASH_SHA1_SIZE) < 0) goto cleanup; if (git_hash_buf(hash, data, size, GIT_HASH_ALGORITHM_SHA1) < 0) { fprintf(stderr, "Failed to compute the SHA1 hash\n"); @@ -62,10 +61,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) memcpy(oid.id, hash, GIT_OID_RAWSZ); } else { - git_buf_attach_notowned(&midx_buf, (char *)data, size); + git_str_attach_notowned(&midx_buf, (char *)data, size); } - if (git_midx_parse(&idx, (const unsigned char *)git_buf_cstr(&midx_buf), git_buf_len(&midx_buf)) < 0) + if (git_midx_parse(&idx, (const unsigned char *)git_str_cstr(&midx_buf), git_str_len(&midx_buf)) < 0) goto cleanup; /* Search for any oid, just to exercise that codepath. */ @@ -74,6 +73,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) cleanup: git_midx_close(&idx); - git_buf_dispose(&midx_buf); + git_str_dispose(&midx_buf); return 0; } diff --git a/fuzzers/packfile_fuzzer.c b/fuzzers/packfile_fuzzer.c index 50c115755..f739b9563 100644 --- a/fuzzers/packfile_fuzzer.c +++ b/fuzzers/packfile_fuzzer.c @@ -12,7 +12,7 @@ #include "git2.h" #include "git2/sys/mempack.h" #include "common.h" -#include "buffer.h" +#include "str.h" static git_odb *odb = NULL; static git_odb_backend *mempack = NULL; @@ -53,7 +53,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { git_indexer_progress stats = {0, 0}; git_indexer *indexer = NULL; - git_buf path = GIT_BUF_INIT; + git_str path = GIT_STR_INIT; git_oid oid; bool append_hash = false; @@ -99,19 +99,19 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) if (git_indexer_commit(indexer, &stats) < 0) goto cleanup; - if (git_buf_printf(&path, "pack-%s.idx", git_oid_tostr_s(git_indexer_hash(indexer))) < 0) + if (git_str_printf(&path, "pack-%s.idx", git_oid_tostr_s(git_indexer_hash(indexer))) < 0) goto cleanup; - p_unlink(git_buf_cstr(&path)); + p_unlink(git_str_cstr(&path)); - git_buf_clear(&path); + git_str_clear(&path); - if (git_buf_printf(&path, "pack-%s.pack", git_oid_tostr_s(git_indexer_hash(indexer))) < 0) + if (git_str_printf(&path, "pack-%s.pack", git_oid_tostr_s(git_indexer_hash(indexer))) < 0) goto cleanup; - p_unlink(git_buf_cstr(&path)); + p_unlink(git_str_cstr(&path)); cleanup: git_mempack_reset(mempack); git_indexer_free(indexer); - git_buf_dispose(&path); + git_str_dispose(&path); return 0; } diff --git a/fuzzers/standalone_driver.c b/fuzzers/standalone_driver.c index 90e701333..88c8cfbda 100644 --- a/fuzzers/standalone_driver.c +++ b/fuzzers/standalone_driver.c @@ -16,7 +16,7 @@ extern int LLVMFuzzerInitialize(int *argc, char ***argv); static int run_one_file(const char *filename) { - git_buf buf = GIT_BUF_INIT; + git_str buf = GIT_STR_INIT; int error = 0; if (git_futils_readbuffer(&buf, filename) < 0) { @@ -27,7 +27,7 @@ static int run_one_file(const char *filename) LLVMFuzzerTestOneInput((const unsigned char *)buf.ptr, buf.size); exit: - git_buf_dispose(&buf); + git_str_dispose(&buf); return error; } |