diff options
-rw-r--r-- | src/openssl.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/openssl.c b/src/openssl.c index fa7dd79..900b909 100644 --- a/src/openssl.c +++ b/src/openssl.c | |||
@@ -4958,6 +4958,25 @@ static _Bool xe_new_isder(const char *value, _Bool *crit) { | |||
4958 | return 0; | 4958 | return 0; |
4959 | } /* xs_new_isder() */ | 4959 | } /* xs_new_isder() */ |
4960 | 4960 | ||
4961 | static CONF* loadconf(lua_State *L, int idx) { | ||
4962 | CONF *conf; | ||
4963 | size_t len; | ||
4964 | const char *cdata = luaL_checklstring(L, idx, &len); | ||
4965 | BIO *bio = getbio(L); | ||
4966 | if (BIO_write(bio, cdata, len) < 0) | ||
4967 | return NULL; | ||
4968 | |||
4969 | if (!(conf = NCONF_new(NULL))) | ||
4970 | return NULL; | ||
4971 | |||
4972 | if (!NCONF_load_bio(conf, bio, NULL)) { | ||
4973 | NCONF_free(conf); | ||
4974 | return NULL; | ||
4975 | } | ||
4976 | |||
4977 | return conf; | ||
4978 | } | ||
4979 | |||
4961 | static int xe_new(lua_State *L) { | 4980 | static int xe_new(lua_State *L) { |
4962 | const char *name = luaL_checkstring(L, 1); | 4981 | const char *name = luaL_checkstring(L, 1); |
4963 | const char *value = luaL_checkstring(L, 2); | 4982 | const char *value = luaL_checkstring(L, 2); |
@@ -4991,13 +5010,7 @@ static int xe_new(lua_State *L) { | |||
4991 | return 1; | 5010 | return 1; |
4992 | } | 5011 | } |
4993 | 5012 | ||
4994 | BIO *bio = getbio(L); | 5013 | if (!(conf = loadconf(L, 3))) |
4995 | if (BIO_puts(bio, cdata) < 0) | ||
4996 | goto error; | ||
4997 | |||
4998 | if (!(conf = NCONF_new(NULL))) | ||
4999 | goto error; | ||
5000 | if (!NCONF_load_bio(conf, bio, NULL)) | ||
5001 | goto error; | 5014 | goto error; |
5002 | 5015 | ||
5003 | ctx = &cbuf; | 5016 | ctx = &cbuf; |