summaryrefslogtreecommitdiff
path: root/fuzzers
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2019-06-28 11:04:21 +0200
committerPatrick Steinhardt <ps@pks.im>2019-07-05 11:58:33 +0200
commita6b2fffd46ff72dc3a976dcbdf5024ef0964106c (patch)
tree79a0f49a2176bec427b4c2eed3e97085ae50953e /fuzzers
parent69055813046366967563e0b78ee29113ef610886 (diff)
downloadlibgit2-a6b2fffd46ff72dc3a976dcbdf5024ef0964106c.tar.gz
fuzzers: use POSIX emulation layer to unlink files
Use `p_unlink` instead of `unlink` to remove the generated packfiles in our packfile fuzzer. Like this, we do not have to worry about using proper includes that are known on all platforms, especially Win32.
Diffstat (limited to 'fuzzers')
-rw-r--r--fuzzers/packfile_fuzzer.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/fuzzers/packfile_fuzzer.c b/fuzzers/packfile_fuzzer.c
index f5e6718ed..b42c6f5df 100644
--- a/fuzzers/packfile_fuzzer.c
+++ b/fuzzers/packfile_fuzzer.c
@@ -15,8 +15,7 @@
#include "git2.h"
#include "git2/sys/mempack.h"
-
-#define UNUSED(x) (void)(x)
+#include "common.h"
static git_odb *odb = NULL;
static git_odb_backend *mempack = NULL;
@@ -27,8 +26,9 @@ static const unsigned int base_obj_len = 2;
int LLVMFuzzerInitialize(int *argc, char ***argv)
{
- UNUSED(argc);
- UNUSED(argv);
+ GIT_UNUSED(argc);
+ GIT_UNUSED(argv);
+
if (git_libgit2_init() < 0) {
fprintf(stderr, "Failed to initialize libgit2\n");
abort();
@@ -59,7 +59,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
bool append_hash = false;
git_oid id;
char hash[GIT_OID_HEXSZ + 1] = {0};
- char path[PATH_MAX];
+ char path[GIT_PATH_MAX];
if (size == 0)
return 0;
@@ -111,9 +111,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
git_oid_fmt(hash, git_indexer_hash(indexer));
printf("Generated packfile %s\n", hash);
snprintf(path, sizeof(path), "pack-%s.idx", hash);
- unlink(path);
+ p_unlink(path);
snprintf(path, sizeof(path), "pack-%s.pack", hash);
- unlink(path);
+ p_unlink(path);
cleanup:
git_mempack_reset(mempack);