46 lines
1.5 KiB
Diff
46 lines
1.5 KiB
Diff
|
--- cryptography-2.2.2/src/_cffi_src/openssl/src/osrandom_engine.c 2018-03-27 15:12:05.000000000 +0100
|
||
|
+++ cryptography-2.2.2-patch/src/_cffi_src/openssl/src/osrandom_engine.c 2018-06-02 05:21:49.000000000 +0100
|
||
|
@@ -205,14 +205,10 @@
|
||
|
#if !defined(__APPLE__)
|
||
|
getentropy_works = CRYPTOGRAPHY_OSRANDOM_GETENTROPY_WORKS;
|
||
|
#else
|
||
|
- if (&getentropy != NULL) {
|
||
|
- getentropy_works = CRYPTOGRAPHY_OSRANDOM_GETENTROPY_WORKS;
|
||
|
- } else {
|
||
|
- getentropy_works = CRYPTOGRAPHY_OSRANDOM_GETENTROPY_FALLBACK;
|
||
|
- int fd = dev_urandom_fd();
|
||
|
- if (fd < 0) {
|
||
|
- return 0;
|
||
|
- }
|
||
|
+ getentropy_works = CRYPTOGRAPHY_OSRANDOM_GETENTROPY_FALLBACK;
|
||
|
+ int fd = dev_urandom_fd();
|
||
|
+ if (fd < 0) {
|
||
|
+ return 0;
|
||
|
}
|
||
|
#endif
|
||
|
return 1;
|
||
|
@@ -228,22 +224,7 @@
|
||
|
return dev_urandom_read(buffer, size);
|
||
|
#endif
|
||
|
case CRYPTOGRAPHY_OSRANDOM_GETENTROPY_WORKS:
|
||
|
- while (size > 0) {
|
||
|
- /* OpenBSD and macOS restrict maximum buffer size to 256. */
|
||
|
- len = size > 256 ? 256 : (size_t)size;
|
||
|
- res = getentropy(buffer, len);
|
||
|
- if (res < 0) {
|
||
|
- ERR_Cryptography_OSRandom_error(
|
||
|
- CRYPTOGRAPHY_OSRANDOM_F_RAND_BYTES,
|
||
|
- CRYPTOGRAPHY_OSRANDOM_R_GETENTROPY_FAILED,
|
||
|
- __FILE__, __LINE__
|
||
|
- );
|
||
|
- return 0;
|
||
|
- }
|
||
|
- buffer += len;
|
||
|
- size -= len;
|
||
|
- }
|
||
|
- return 1;
|
||
|
+ return 0;
|
||
|
}
|
||
|
__builtin_unreachable();
|
||
|
}
|