Add a proper write loop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
diff --git a/fuzzers/config_file_fuzzer.c b/fuzzers/config_file_fuzzer.c
index 03009c8..30a47bf 100644
--- a/fuzzers/config_file_fuzzer.c
+++ b/fuzzers/config_file_fuzzer.c
@@ -13,6 +13,7 @@
#include <stdio.h>
#include <unistd.h>
#include <limits.h>
+#include <errno.h>
#define UNUSED(x) (void)(x)
@@ -46,6 +47,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
git_config *cfg = NULL;
int err = 0;
+ size_t total = 0;
if (ftruncate(fd, 0) !=0 ) {
abort();
@@ -53,8 +55,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
if (lseek(fd, 0, SEEK_SET) != 0) {
abort();
}
- if ((size_t)write(fd, data, size) != size) {
- abort();
+
+ while (total < size) {
+ ssize_t written = write(fd, data, size);
+ if (written < 0 && errno != EINTR)
+ abort();
+ if (written < 0)
+ continue;
+ total += written;
}
err = git_config_open_ondisk(&cfg, path);