diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2024-04-18 10:18:44 +0100 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2024-04-18 10:18:44 +0100 |
commit | 09f5a74198c328c80539c17d951a70558e6b361e (patch) | |
tree | 5246342604c3322a6e9c13ec5bfa0710a2173340 /src/test | |
parent | e31956980e16ad3d619022e572bdf55a4eae8716 (diff) |
fuzz: Re-implement `read_stdin` in portable way
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/fuzz/fuzz.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/test/fuzz/fuzz.cpp b/src/test/fuzz/fuzz.cpp index a8e490b459..f9915187bd 100644 --- a/src/test/fuzz/fuzz.cpp +++ b/src/test/fuzz/fuzz.cpp @@ -25,7 +25,6 @@ #include <memory> #include <string> #include <tuple> -#include <unistd.h> #include <utility> #include <vector> @@ -135,9 +134,9 @@ void initialize() #if defined(PROVIDE_FUZZ_MAIN_FUNCTION) static bool read_stdin(std::vector<uint8_t>& data) { - uint8_t buffer[1024]; - ssize_t length = 0; - while ((length = read(STDIN_FILENO, buffer, 1024)) > 0) { + std::istream::char_type buffer[1024]; + std::streamsize length; + while ((std::cin.read(buffer, 1024), length = std::cin.gcount()) > 0) { data.insert(data.end(), buffer, buffer + length); } return length == 0; |