Skip to content

Commit f556dea

Browse files
committed
Add a proper write loop
1 parent b8d4578 commit f556dea

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

fuzzers/config_file_fuzzer.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <stdio.h>
1414
#include <unistd.h>
1515
#include <limits.h>
16+
#include <errno.h>
1617

1718
#define UNUSED(x) (void)(x)
1819

@@ -46,15 +47,22 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
4647
{
4748
git_config *cfg = NULL;
4849
int err = 0;
50+
size_t total = 0;
4951

5052
if (ftruncate(fd, 0) !=0 ) {
5153
abort();
5254
}
5355
if (lseek(fd, 0, SEEK_SET) != 0) {
5456
abort();
5557
}
56-
if ((size_t)write(fd, data, size) != size) {
57-
abort();
58+
59+
while (total < size) {
60+
ssize_t written = write(fd, data, size);
61+
if (written < 0 && errno != EINTR)
62+
abort();
63+
if (written < 0)
64+
continue;
65+
total += written;
5866
}
5967

6068
err = git_config_open_ondisk(&cfg, path);

0 commit comments

Comments
 (0)