fuzz: Re-implement read_stdin in portable way
This commit is contained in:
1 file changed
+3
-4
@@ -25,7 +25,6 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <unistd.h>
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -135,9 +134,9 @@ void initialize()
|
|||||||
#if defined(PROVIDE_FUZZ_MAIN_FUNCTION)
|
#if defined(PROVIDE_FUZZ_MAIN_FUNCTION)
|
||||||
static bool read_stdin(std::vector<uint8_t>& data)
|
static bool read_stdin(std::vector<uint8_t>& data)
|
||||||
{
|
{
|
||||||
uint8_t buffer[1024];
|
std::istream::char_type buffer[1024];
|
||||||
ssize_t length = 0;
|
std::streamsize length;
|
||||||
while ((length = read(STDIN_FILENO, buffer, 1024)) > 0) {
|
while ((std::cin.read(buffer, 1024), length = std::cin.gcount()) > 0) {
|
||||||
data.insert(data.end(), buffer, buffer + length);
|
data.insert(data.end(), buffer, buffer + length);
|
||||||
}
|
}
|
||||||
return length == 0;
|
return length == 0;
|
||||||
|
|||||||
Reference in new issue
Block a user