diff options
author | william <william@25thandclement.com> | 2015-03-05 14:28:50 -0800 |
---|---|---|
committer | william <william@25thandclement.com> | 2015-03-05 14:28:50 -0800 |
commit | fe19dfb57495c54c16edbeb52eae64b01404364f (patch) | |
tree | b2548bd3b329c1ed1f1ed67c396c423f6abbea0a /src | |
parent | c20f5535ccd9554390a2d0d71d4eb1fb4c104e7b (diff) | |
download | luaossl-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)
Diffstat (limited to 'src')
-rw-r--r-- | src/openssl.c | 12 |
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 @@ | |||
33 | #include <math.h> /* INFINITY fabs(3) floor(3) frexp(3) fmod(3) round(3) isfinite(3) */ | 33 | #include <math.h> /* INFINITY fabs(3) floor(3) frexp(3) fmod(3) round(3) isfinite(3) */ |
34 | #include <time.h> /* struct tm time_t strptime(3) time(2) */ | 34 | #include <time.h> /* struct tm time_t strptime(3) time(2) */ |
35 | #include <ctype.h> /* tolower(3) */ | 35 | #include <ctype.h> /* tolower(3) */ |
36 | #include <errno.h> /* errno */ | 36 | #include <errno.h> /* ENOMEM errno */ |
37 | 37 | ||
38 | #include <sys/types.h> /* ssize_t pid_t */ | 38 | #include <sys/types.h> /* ssize_t pid_t */ |
39 | #if !defined __sun && !defined _AIX | 39 | #if !defined __sun && !defined _AIX |
@@ -4554,9 +4554,15 @@ static int sx_setAlpnProtos(lua_State *L) { | |||
4554 | done: | 4554 | done: |
4555 | luaL_pushresult(&B); | 4555 | luaL_pushresult(&B); |
4556 | tmp = lua_tolstring(L, -1, &len); | 4556 | tmp = lua_tolstring(L, -1, &len); |
4557 | |||
4558 | /* OpenSSL 1.0.2 doesn't update the error stack on failure. */ | ||
4559 | ERR_clear_error(); | ||
4557 | if (0 != SSL_CTX_set_alpn_protos(ctx, (const unsigned char*)tmp, len)) { | 4560 | if (0 != SSL_CTX_set_alpn_protos(ctx, (const unsigned char*)tmp, len)) { |
4558 | lua_pushnil(L); | 4561 | if (!ERR_peek_error()) { |
4559 | return 1; | 4562 | return luaL_error(L, "unable to set ALPN protocols: %s", xstrerror(ENOMEM)); |
4563 | } else { | ||
4564 | return throwssl(L, "ssl.context:setAlpnProtos"); | ||
4565 | } | ||
4560 | } | 4566 | } |
4561 | 4567 | ||
4562 | lua_pushboolean(L, 1); | 4568 | lua_pushboolean(L, 1); |