aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarLibravatar william <william@25thandclement.com> 2015-03-05 14:28:50 -0800
committerLibravatarLibravatar william <william@25thandclement.com> 2015-03-05 14:28:50 -0800
commitfe19dfb57495c54c16edbeb52eae64b01404364f (patch)
treeb2548bd3b329c1ed1f1ed67c396c423f6abbea0a
parentc20f5535ccd9554390a2d0d71d4eb1fb4c104e7b (diff)
downloadluaossl-fe19dfb57495c54c16edbeb52eae64b01404364f.tar.gz
luaossl-fe19dfb57495c54c16edbeb52eae64b01404364f.tar.bz2
luaossl-fe19dfb57495c54c16edbeb52eae64b01404364f.zip
throw error when SSL_CTX_set_alpn_protos fails (which pesently is always an allocation failure)
-rw-r--r--src/openssl.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/openssl.c b/src/openssl.c
index 2b0cb88..2dee037 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -33,7 +33,7 @@
#include <math.h> /* INFINITY fabs(3) floor(3) frexp(3) fmod(3) round(3) isfinite(3) */
#include <time.h> /* struct tm time_t strptime(3) time(2) */
#include <ctype.h> /* tolower(3) */
-#include <errno.h> /* errno */
+#include <errno.h> /* ENOMEM errno */
#include <sys/types.h> /* ssize_t pid_t */
#if !defined __sun && !defined _AIX
@@ -4554,9 +4554,15 @@ static int sx_setAlpnProtos(lua_State *L) {
done:
luaL_pushresult(&B);
tmp = lua_tolstring(L, -1, &len);
+
+ /* OpenSSL 1.0.2 doesn't update the error stack on failure. */
+ ERR_clear_error();
if (0 != SSL_CTX_set_alpn_protos(ctx, (const unsigned char*)tmp, len)) {
- lua_pushnil(L);
- return 1;
+ if (!ERR_peek_error()) {
+ return luaL_error(L, "unable to set ALPN protocols: %s", xstrerror(ENOMEM));
+ } else {
+ return throwssl(L, "ssl.context:setAlpnProtos");
+ }
}
lua_pushboolean(L, 1);