diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:06:48 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:06:48 +0000 |
commit | 93c1b73a09a52d4a265f683bf1954b08bb430049 (patch) | |
tree | 5543464d74945196cc890e9d9099e5d0660df7eb /lib/fuzzer/FuzzerShmemPosix.cpp | |
parent | 0d8e7490d6e8a13a8f0977d9b7771803b9f64ea0 (diff) | |
download | src-cb16fceba18bd147132c980a4697049b0d0215ed.tar.gz src-cb16fceba18bd147132c980a4697049b0d0215ed.zip |
Vendor import of compiler-rt trunk r338150:vendor/compiler-rt/compiler-rt-trunk-r338150
Diffstat (limited to 'lib/fuzzer/FuzzerShmemPosix.cpp')
-rw-r--r-- | lib/fuzzer/FuzzerShmemPosix.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/fuzzer/FuzzerShmemPosix.cpp b/lib/fuzzer/FuzzerShmemPosix.cpp index 50cdcfb509dc..41a93f61004b 100644 --- a/lib/fuzzer/FuzzerShmemPosix.cpp +++ b/lib/fuzzer/FuzzerShmemPosix.cpp @@ -32,6 +32,11 @@ std::string SharedMemoryRegion::Path(const char *Name) { std::string SharedMemoryRegion::SemName(const char *Name, int Idx) { std::string Res(Name); + // When passing a name without a leading <slash> character to + // sem_open, the behaviour is unspecified in POSIX. Add a leading + // <slash> character for the name if there is no such one. + if (!Res.empty() && Res[0] != '/') + Res.insert(Res.begin(), '/'); return Res + (char)('0' + Idx); } @@ -52,7 +57,7 @@ bool SharedMemoryRegion::Create(const char *Name) { for (int i = 0; i < 2; i++) { sem_unlink(SemName(Name, i).c_str()); Semaphore[i] = sem_open(SemName(Name, i).c_str(), O_CREAT, 0644, 0); - if (Semaphore[i] == (void *)-1) + if (Semaphore[i] == SEM_FAILED) return false; } IAmServer = true; @@ -70,7 +75,7 @@ bool SharedMemoryRegion::Open(const char *Name) { return false; for (int i = 0; i < 2; i++) { Semaphore[i] = sem_open(SemName(Name, i).c_str(), 0); - if (Semaphore[i] == (void *)-1) + if (Semaphore[i] == SEM_FAILED) return false; } IAmServer = false; |