diff options
author | daurnimator <quae@daurnimator.com> | 2018-05-29 13:10:49 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2018-05-29 13:33:44 +1000 |
commit | 6aaf6adfe40e629ead457f2696fa3d8139b59883 (patch) | |
tree | 605bfefe31b7274c599dafea44559a804cc53cd0 | |
parent | c8c895ae4bcb1aed1a65c79b168fecd7eb29f5de (diff) | |
download | luaossl-6aaf6adfe40e629ead457f2696fa3d8139b59883.tar.gz luaossl-6aaf6adfe40e629ead457f2696fa3d8139b59883.tar.bz2 luaossl-6aaf6adfe40e629ead457f2696fa3d8139b59883.zip |
src/openssl.c: Factor out xc_dup function
-rw-r--r-- | src/openssl.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/openssl.c b/src/openssl.c index 87e0723..8efe6f7 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -5648,6 +5648,18 @@ EXPORT int luaopen__openssl_x509_extension(lua_State *L) { * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +static void xc_dup(lua_State *L, X509 *x509) { + X509 **ud = prepsimple(L, X509_CERT_CLASS); + + if (!(*ud = X509_dup(x509))) + goto error; + + return; +error: + auxL_error(L, auxL_EOPENSSL, "X509_dup"); +} /* xc_dup() */ + + static int xc_new(lua_State *L) { const char *data; size_t len; @@ -7713,10 +7725,7 @@ static int xl__next(lua_State *L) { lua_pushinteger(L, i); - ret = prepsimple(L, X509_CERT_CLASS); - - if (!(*ret = X509_dup(crt))) - return auxL_error(L, auxL_EOPENSSL, "x509.chain:__next"); + xc_dup(L, crt); break; } |