Enable GetRandom for Fuchsia sanitizer.

Summary: Adds a true implementation of GetRandom, to be used by scudo_utils.h.

Reviewers: mcgrathr, phosek, kcc, vitalybuka, cryptoad

Reviewed By: mcgrathr

Subscribers: kubamracek

Differential Revision: https://reviews.llvm.org/D37218

llvm-svn: 312046
This commit is contained in:
Kostya Kortchinsky 2017-08-29 21:52:56 +00:00
parent ebb9327759
commit 913d038b29
1 changed files with 8 additions and 0 deletions

View File

@ -480,6 +480,14 @@ uptr ReadLongProcessName(/*out*/ char *buf, uptr buf_len) {
uptr MainThreadStackBase, MainThreadStackSize;
bool GetRandom(void *buffer, uptr length, bool blocking) {
CHECK_LE(length, MX_CPRNG_DRAW_MAX_LEN);
size_t size;
CHECK_EQ(_mx_cprng_draw(buffer, length, &size), MX_OK);
CHECK_EQ(size, length);
return true;
}
} // namespace __sanitizer
using namespace __sanitizer; // NOLINT