diff options
author | william <william+ubuntu@25thandClement.com> | 2015-03-05 16:49:17 -0800 |
---|---|---|
committer | william <william+ubuntu@25thandClement.com> | 2015-03-05 16:49:17 -0800 |
commit | 1a8c2c902dfa982fd387279dfe99dd270d2ecf89 (patch) | |
tree | ef9b573b07852e2d090dcd173ccef42eea4ea950 /src | |
parent | 8fe044b632f04c4d7bf07f3f60b97d45f39ecd26 (diff) | |
download | luaossl-1a8c2c902dfa982fd387279dfe99dd270d2ecf89.tar.gz luaossl-1a8c2c902dfa982fd387279dfe99dd270d2ecf89.tar.bz2 luaossl-1a8c2c902dfa982fd387279dfe99dd270d2ecf89.zip |
fix strerror_r usage on glibc
Diffstat (limited to 'src')
-rw-r--r-- | src/openssl.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/openssl.c b/src/openssl.c index 773930b..c1b5436 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -95,6 +95,10 @@ #define HAVE_SSL_GET0_ALPN_SELECTED HAVE_SSL_CTX_SET_ALPN_PROTOS #endif +#ifndef STRERROR_R_CHAR_P +#define STRERROR_R_CHAR_P (defined __GLIBC__ && (_GNU_SOURCE || !(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600))) +#endif + #define BIGNUM_CLASS "BIGNUM*" #define PKEY_CLASS "EVP_PKEY*" #define X509_NAME_CLASS "X509_NAME*" @@ -178,8 +182,17 @@ static const char *xstrerror_r(int error, char *dst, size_t lim) { static const char unknown[] = "Unknown error: "; size_t n; - if (0 == strerror_r(error, dst, lim) && *dst != '\0') +#if STRERROR_R_CHAR_P + char *rv = strerror_r(error, dst, lim); + + if (rv != NULL) return dst; +#else + int rv = strerror_r(error, dst, lim); + + if (0 == rv) + return dst; +#endif /* * glibc snprintf can fail on memory pressure, so format our number |