Skip to content

Commit 09f5a74

Browse files
committed
fuzz: Re-implement read_stdin in portable way
1 parent e319569 commit 09f5a74

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/test/fuzz/fuzz.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <memory>
2626
#include <string>
2727
#include <tuple>
28-
#include <unistd.h>
2928
#include <utility>
3029
#include <vector>
3130

@@ -135,9 +134,9 @@ void initialize()
135134
#if defined(PROVIDE_FUZZ_MAIN_FUNCTION)
136135
static bool read_stdin(std::vector<uint8_t>& data)
137136
{
138-
uint8_t buffer[1024];
139-
ssize_t length = 0;
140-
while ((length = read(STDIN_FILENO, buffer, 1024)) > 0) {
137+
std::istream::char_type buffer[1024];
138+
std::streamsize length;
139+
while ((std::cin.read(buffer, 1024), length = std::cin.gcount()) > 0) {
141140
data.insert(data.end(), buffer, buffer + length);
142141
}
143142
return length == 0;

0 commit comments

Comments
 (0)