void RemoveFile(const std::string &Path);
void RenameFile(const std::string &OldPath, const std::string &NewPath);
-void DiscardOutput(int Fd);
-
intptr_t GetHandleFromFd(int fd);
void MkDir(const std::string &Path);
rename(OldPath.c_str(), NewPath.c_str());
}
-void DiscardOutput(int Fd) {
- FILE* Temp = fopen("/dev/null", "w");
- if (!Temp)
- return;
- dup2(fileno(Temp), Fd);
- fclose(Temp);
-}
-
intptr_t GetHandleFromFd(int fd) {
return static_cast<intptr_t>(fd);
}
rename(OldPath.c_str(), NewPath.c_str());
}
-void DiscardOutput(int Fd) {
- FILE* Temp = fopen("nul", "w");
- if (!Temp)
- return;
- _dup2(_fileno(Temp), Fd);
- fclose(Temp);
-}
-
intptr_t GetHandleFromFd(int fd) {
return _get_osfhandle(fd);
}
return std::make_pair(S.substr(0, Pos), S.substr(Pos));
}
+void DiscardOutput(int Fd);
+
std::string DisassembleCmd(const std::string &FileName);
std::string SearchRegexCmd(const std::string &Regex);
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
+#include <unistd.h>
// There is no header for this on macOS so declare here
extern "C" char **environ;
return ProcessStatus;
}
+void DiscardOutput(int Fd) {
+ FILE* Temp = fopen("/dev/null", "w");
+ if (!Temp)
+ return;
+ dup2(fileno(Temp), Fd);
+ fclose(Temp);
+}
+
} // namespace fuzzer
#endif // LIBFUZZER_APPLE
#include <cinttypes>
#include <cstdint>
#include <fcntl.h>
+#include <lib/fdio/fdio.h>
#include <lib/fdio/spawn.h>
#include <string>
#include <sys/select.h>
return memmem(Data, DataLen, Patt, PattLen);
}
+// In fuchsia, accessing /dev/null is not supported. There's nothing
+// similar to a file that discards everything that is written to it.
+// The way of doing something similar in fuchsia is by using
+// fdio_null_create and binding that to a file descriptor.
+void DiscardOutput(int Fd) {
+ fdio_t *fdio_null = fdio_null_create();
+ if (fdio_null == nullptr) return;
+ int nullfd = fdio_bind_to_fd(fdio_null, -1, 0);
+ if (nullfd < 0) return;
+ dup2(nullfd, Fd);
+}
+
} // namespace fuzzer
#endif // LIBFUZZER_FUCHSIA
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <unistd.h>
namespace fuzzer {
return exit_code;
}
+void DiscardOutput(int Fd) {
+ FILE* Temp = fopen("/dev/null", "w");
+ if (!Temp)
+ return;
+ dup2(fileno(Temp), Fd);
+ fclose(Temp);
+}
+
} // namespace fuzzer
#endif
#include <chrono>
#include <cstring>
#include <errno.h>
+#include <io.h>
#include <iomanip>
#include <signal.h>
#include <stdio.h>
return "findstr /r \"" + Regex + "\"";
}
+void DiscardOutput(int Fd) {
+ FILE* Temp = fopen("nul", "w");
+ if (!Temp)
+ return;
+ _dup2(_fileno(Temp), Fd);
+ fclose(Temp);
+}
+
} // namespace fuzzer
#endif // LIBFUZZER_WINDOWS