summaryrefslogtreecommitdiff
path: root/fuzzers/config_file_fuzzer.c
diff options
context:
space:
mode:
authorNelson Elhage <nelhage@nelhage.com>2018-08-14 03:55:58 +0000
committerNelson Elhage <nelhage@nelhage.com>2018-08-14 03:55:58 +0000
commit8189642d244e0b55d5202fa775c3c9a8f54eea83 (patch)
treeb79faf511c9a08677cd0a8beb5aa89077d7aaf9b /fuzzers/config_file_fuzzer.c
parentbcfa762b361cceac603ae448f3b47b9b5254cdd3 (diff)
downloadlibgit2-8189642d244e0b55d5202fa775c3c9a8f54eea83.tar.gz
Reformat
Diffstat (limited to 'fuzzers/config_file_fuzzer.c')
-rw-r--r--fuzzers/config_file_fuzzer.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/fuzzers/config_file_fuzzer.c b/fuzzers/config_file_fuzzer.c
index eafcd1093..869812029 100644
--- a/fuzzers/config_file_fuzzer.c
+++ b/fuzzers/config_file_fuzzer.c
@@ -5,37 +5,38 @@
#include <unistd.h>
#include <limits.h>
-int foreach_cb(const git_config_entry *entry, void *payload) {
- return 0;
+int foreach_cb(const git_config_entry *entry, void *payload)
+{
+ return 0;
}
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
- static int fd = -1;
- static char path[] = "/tmp/git.XXXXXX";
- if (fd < 0) {
- git_libgit2_init();
- fd = mkstemp(path);
- if (fd < 0) {
- abort();
- }
- }
- if (ftruncate(fd, 0) !=0 ) {
- abort();
- }
- if (lseek(fd, 0, SEEK_SET) != 0) {
- abort();
- }
- if (write(fd, data, size) != size) {
- abort();
- }
+ static int fd = -1;
+ static char path[] = "/tmp/git.XXXXXX";
+ if (fd < 0) {
+ git_libgit2_init();
+ fd = mkstemp(path);
+ if (fd < 0) {
+ abort();
+ }
+ }
+ if (ftruncate(fd, 0) !=0 ) {
+ abort();
+ }
+ if (lseek(fd, 0, SEEK_SET) != 0) {
+ abort();
+ }
+ if (write(fd, data, size) != size) {
+ abort();
+ }
- git_config *cfg;
- int err = git_config_open_ondisk(&cfg, path);
- if (err == 0) {
- git_config_foreach(cfg, foreach_cb, NULL);
- git_config_free(cfg);
- }
+ git_config *cfg;
+ int err = git_config_open_ondisk(&cfg, path);
+ if (err == 0) {
+ git_config_foreach(cfg, foreach_cb, NULL);
+ git_config_free(cfg);
+ }
- return 0;
+ return 0;
}