Commit 8189642d by Nelson Elhage

Reformat

parent bcfa762b
...@@ -5,37 +5,38 @@ ...@@ -5,37 +5,38 @@
#include <unistd.h> #include <unistd.h>
#include <limits.h> #include <limits.h>
int foreach_cb(const git_config_entry *entry, void *payload) { int foreach_cb(const git_config_entry *entry, void *payload)
return 0; {
return 0;
} }
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{ {
static int fd = -1; static int fd = -1;
static char path[] = "/tmp/git.XXXXXX"; static char path[] = "/tmp/git.XXXXXX";
if (fd < 0) { if (fd < 0) {
git_libgit2_init(); git_libgit2_init();
fd = mkstemp(path); fd = mkstemp(path);
if (fd < 0) { if (fd < 0) {
abort(); abort();
} }
} }
if (ftruncate(fd, 0) !=0 ) { if (ftruncate(fd, 0) !=0 ) {
abort(); abort();
} }
if (lseek(fd, 0, SEEK_SET) != 0) { if (lseek(fd, 0, SEEK_SET) != 0) {
abort(); abort();
} }
if (write(fd, data, size) != size) { if (write(fd, data, size) != size) {
abort(); abort();
} }
git_config *cfg; git_config *cfg;
int err = git_config_open_ondisk(&cfg, path); int err = git_config_open_ondisk(&cfg, path);
if (err == 0) { if (err == 0) {
git_config_foreach(cfg, foreach_cb, NULL); git_config_foreach(cfg, foreach_cb, NULL);
git_config_free(cfg); git_config_free(cfg);
} }
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment