Skip to content

Commit 913d038

Browse files
author
Kostya Kortchinsky
committed
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
1 parent ebb9327 commit 913d038

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,14 @@ uptr ReadLongProcessName(/*out*/ char *buf, uptr buf_len) {
480480

481481
uptr MainThreadStackBase, MainThreadStackSize;
482482

483+
bool GetRandom(void *buffer, uptr length, bool blocking) {
484+
CHECK_LE(length, MX_CPRNG_DRAW_MAX_LEN);
485+
size_t size;
486+
CHECK_EQ(_mx_cprng_draw(buffer, length, &size), MX_OK);
487+
CHECK_EQ(size, length);
488+
return true;
489+
}
490+
483491
} // namespace __sanitizer
484492

485493
using namespace __sanitizer; // NOLINT

0 commit comments

Comments
 (0)