diff options
| author | Max Bélanger <aeromax@gmail.com> | 2019-10-23 15:40:42 -0700 | 
|---|---|---|
| committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2019-10-24 06:40:42 +0800 | 
| commit | e400dc061ddbd505bbb4f3fe9797682e314717fb (patch) | |
| tree | f2d96b24389271fb925699a3f36df269b96b3b59 /src/_cffi_src | |
| parent | 95a886a807aa6c8a7eb5cfcc1327e954b3402b62 (diff) | |
| download | cryptography-e400dc061ddbd505bbb4f3fe9797682e314717fb.tar.gz cryptography-e400dc061ddbd505bbb4f3fe9797682e314717fb.tar.bz2 cryptography-e400dc061ddbd505bbb4f3fe9797682e314717fb.zip | |
Silence unguarded availability warnings for `getentropy` when targeting macOS 10.12 (#5019)
* silence `Wunguarded-availability` when building with a `MACOSX_DEPLOYMENT_TARGET < 10.12`
* use `__builtin_available` rather than a `NULL` echo upon init on mac
Diffstat (limited to 'src/_cffi_src')
| -rw-r--r-- | src/_cffi_src/openssl/src/osrandom_engine.c | 6 | 
1 files changed, 5 insertions, 1 deletions
| diff --git a/src/_cffi_src/openssl/src/osrandom_engine.c b/src/_cffi_src/openssl/src/osrandom_engine.c index 1b893ec7..dc7b1d5e 100644 --- a/src/_cffi_src/openssl/src/osrandom_engine.c +++ b/src/_cffi_src/openssl/src/osrandom_engine.c @@ -251,7 +251,7 @@ static int osrandom_init(ENGINE *e) {  #if !defined(__APPLE__)      getentropy_works = CRYPTOGRAPHY_OSRANDOM_GETENTROPY_WORKS;  #else -    if (&getentropy != NULL) { +    if (__builtin_available(macOS 10.12, *)) {          getentropy_works = CRYPTOGRAPHY_OSRANDOM_GETENTROPY_WORKS;      } else {          getentropy_works = CRYPTOGRAPHY_OSRANDOM_GETENTROPY_FALLBACK; @@ -277,7 +277,11 @@ static int osrandom_rand_bytes(unsigned char *buffer, int size) {          while (size > 0) {              /* OpenBSD and macOS restrict maximum buffer size to 256. */              len = size > 256 ? 256 : size; +/* on mac, availability is already checked using `__builtin_available` above */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunguarded-availability"              res = getentropy(buffer, (size_t)len); +#pragma clang diagnostic pop              if (res < 0) {                  ERR_Cryptography_OSRandom_error(                      CRYPTOGRAPHY_OSRANDOM_F_RAND_BYTES, | 
