| Index: runtime/bin/crypto_android.cc
|
| diff --git a/runtime/bin/crypto_android.cc b/runtime/bin/crypto_android.cc
|
| index 9a81ed17e9ff25f9d9c9fbf4fba2ac3100a29e3c..4b55b910146141e8ad1a9277c76909f9d7eada9e 100644
|
| --- a/runtime/bin/crypto_android.cc
|
| +++ b/runtime/bin/crypto_android.cc
|
| @@ -18,11 +18,24 @@ namespace dart {
|
| namespace bin {
|
|
|
| bool Crypto::GetRandomBytes(intptr_t count, uint8_t* buffer) {
|
| - intptr_t fd = TEMP_FAILURE_RETRY(open("/dev/urandom", O_RDONLY));
|
| + ThreadSignalBlocker signal_blocker(SIGPROF);
|
| + intptr_t fd = TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(
|
| + open("/dev/urandom", O_RDONLY));
|
| if (fd < 0) return false;
|
| - intptr_t bytes_read = FDUtils::ReadFromBlocking(fd, buffer, count);
|
| - VOID_TEMP_FAILURE_RETRY(close(fd));
|
| - return bytes_read == count;
|
| + intptr_t bytes_read = 0;
|
| + do {
|
| + int res = TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(
|
| + read(fd, buffer + bytes_read, count - bytes_read));
|
| + if (res < 0) {
|
| + int err = errno;
|
| + VOID_TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(close(fd));
|
| + errno = err;
|
| + return false;
|
| + }
|
| + bytes_read += res;
|
| + } while (bytes_read < count);
|
| + VOID_TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(close(fd));
|
| + return true;
|
| }
|
|
|
| } // namespace bin
|
|
|