mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 00:36:06 +00:00
[compiler-rt] making getrandom call blocking. (#78340)
except when `GRND_NONBLOCK` is present in the flags.
This commit is contained in:
parent
f01b6ca8be
commit
d83d1cb89c
@ -9965,7 +9965,13 @@ INTERCEPTOR(void, sl_free, void *sl, int freeall) {
|
||||
INTERCEPTOR(SSIZE_T, getrandom, void *buf, SIZE_T buflen, unsigned int flags) {
|
||||
void *ctx;
|
||||
COMMON_INTERCEPTOR_ENTER(ctx, getrandom, buf, buflen, flags);
|
||||
SSIZE_T n = REAL(getrandom)(buf, buflen, flags);
|
||||
// If GRND_NONBLOCK is set in the flags, it is non blocking.
|
||||
static const int grnd_nonblock = 1;
|
||||
SSIZE_T n;
|
||||
if ((flags & grnd_nonblock))
|
||||
n = REAL(getrandom)(buf, buflen, flags);
|
||||
else
|
||||
n = COMMON_INTERCEPTOR_BLOCK_REAL(getrandom)(buf, buflen, flags);
|
||||
if (n > 0) {
|
||||
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, buf, n);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user