mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-13 14:47:00 +00:00
[libFuzzer] Properly use Handle instead of FD on Windows.
For Windows, sanitizers work with Handles, not with posix file descriptors, because they use the windows-specific API. So we need to convert the fds to handles before passing them to the sanitizer library. After this change, close_fd_mask is fixed for Windows (this fix some tests too). Differential Revision: https://reviews.llvm.org/D29548 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294388 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
255eed0380
commit
f80dc2a04d
@ -96,7 +96,8 @@ void DupAndCloseStderr() {
|
|||||||
if (NewOutputFile) {
|
if (NewOutputFile) {
|
||||||
OutputFile = NewOutputFile;
|
OutputFile = NewOutputFile;
|
||||||
if (EF->__sanitizer_set_report_fd)
|
if (EF->__sanitizer_set_report_fd)
|
||||||
EF->__sanitizer_set_report_fd(reinterpret_cast<void *>(OutputFd));
|
EF->__sanitizer_set_report_fd(
|
||||||
|
reinterpret_cast<void *>(GetHandleFromFd(OutputFd)));
|
||||||
DiscardOutput(2);
|
DiscardOutput(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,8 @@ void RemoveFile(const std::string &Path);
|
|||||||
|
|
||||||
void DiscardOutput(int Fd);
|
void DiscardOutput(int Fd);
|
||||||
|
|
||||||
|
intptr_t GetHandleFromFd(int fd);
|
||||||
|
|
||||||
} // namespace fuzzer
|
} // namespace fuzzer
|
||||||
|
|
||||||
#endif // LLVM_FUZZER_IO_H
|
#endif // LLVM_FUZZER_IO_H
|
||||||
|
@ -83,6 +83,10 @@ void DiscardOutput(int Fd) {
|
|||||||
fclose(Temp);
|
fclose(Temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
intptr_t GetHandleFromFd(int fd) {
|
||||||
|
return static_cast<intptr_t>(fd);
|
||||||
|
}
|
||||||
|
|
||||||
std::string DirName(const std::string &FileName) {
|
std::string DirName(const std::string &FileName) {
|
||||||
char *Tmp = new char[FileName.size() + 1];
|
char *Tmp = new char[FileName.size() + 1];
|
||||||
memcpy(Tmp, FileName.c_str(), FileName.size() + 1);
|
memcpy(Tmp, FileName.c_str(), FileName.size() + 1);
|
||||||
|
@ -149,6 +149,10 @@ void DiscardOutput(int Fd) {
|
|||||||
fclose(Temp);
|
fclose(Temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
intptr_t GetHandleFromFd(int fd) {
|
||||||
|
return _get_osfhandle(fd);
|
||||||
|
}
|
||||||
|
|
||||||
static bool IsSeparator(char C) {
|
static bool IsSeparator(char C) {
|
||||||
return C == '\\' || C == '/';
|
return C == '\\' || C == '/';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user