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 | |
parent | 8fe044b632f04c4d7bf07f3f60b97d45f39ecd26 (diff) | |
download | luaossl-1a8c2c902dfa982fd387279dfe99dd270d2ecf89.tar.gz luaossl-1a8c2c902dfa982fd387279dfe99dd270d2ecf89.tar.bz2 luaossl-1a8c2c902dfa982fd387279dfe99dd270d2ecf89.zip |
fix strerror_r usage on glibc
-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 @@ | |||
95 | #define HAVE_SSL_GET0_ALPN_SELECTED HAVE_SSL_CTX_SET_ALPN_PROTOS | 95 | #define HAVE_SSL_GET0_ALPN_SELECTED HAVE_SSL_CTX_SET_ALPN_PROTOS |
96 | #endif | 96 | #endif |
97 | 97 | ||
98 | #ifndef STRERROR_R_CHAR_P | ||
99 | #define STRERROR_R_CHAR_P (defined __GLIBC__ && (_GNU_SOURCE || !(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600))) | ||
100 | #endif | ||
101 | |||
98 | #define BIGNUM_CLASS "BIGNUM*" | 102 | #define BIGNUM_CLASS "BIGNUM*" |
99 | #define PKEY_CLASS "EVP_PKEY*" | 103 | #define PKEY_CLASS "EVP_PKEY*" |
100 | #define X509_NAME_CLASS "X509_NAME*" | 104 | #define X509_NAME_CLASS "X509_NAME*" |
@@ -178,8 +182,17 @@ static const char *xstrerror_r(int error, char *dst, size_t lim) { | |||
178 | static const char unknown[] = "Unknown error: "; | 182 | static const char unknown[] = "Unknown error: "; |
179 | size_t n; | 183 | size_t n; |
180 | 184 | ||
181 | if (0 == strerror_r(error, dst, lim) && *dst != '\0') | 185 | #if STRERROR_R_CHAR_P |
186 | char *rv = strerror_r(error, dst, lim); | ||
187 | |||
188 | if (rv != NULL) | ||
182 | return dst; | 189 | return dst; |
190 | #else | ||
191 | int rv = strerror_r(error, dst, lim); | ||
192 | |||
193 | if (0 == rv) | ||
194 | return dst; | ||
195 | #endif | ||
183 | 196 | ||
184 | /* | 197 | /* |
185 | * glibc snprintf can fail on memory pressure, so format our number | 198 | * glibc snprintf can fail on memory pressure, so format our number |