From a0846fc69bb3e56bf3647f97c8e3ff1df8eacb2e Mon Sep 17 00:00:00 2001 From: daurnimator Date: Mon, 3 Apr 2017 16:20:54 +1000 Subject: Move value='DER' check out of type dispatch in xe_new --- src/openssl.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/openssl.c b/src/openssl.c index 5835a0a..a11e6ae 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -4983,35 +4983,34 @@ static int xe_new(lua_State *L) { CONF *conf = NULL; X509V3_CTX cbuf = { 0 }, *ctx = NULL; X509_EXTENSION **ud; + _Bool crit; lua_settop(L, 3); ud = prepsimple(L, X509_EXT_CLASS); - switch (lua_type(L, 3)) { - case LUA_TNONE: - case LUA_TNIL: - break; - case LUA_TSTRING: { + if (xe_new_isder(value, &crit)) { size_t len; const char *cdata = lua_tolstring(L, 3, &len); - _Bool crit; - - if (xe_new_isder(value, &crit)) { - if (!(obj = OBJ_txt2obj(name, 0))) - goto error; - if (!(oct = ASN1_STRING_new())) - goto error; - if (!ASN1_STRING_set(oct, cdata, len)) - goto error; - if (!(*ud = X509_EXTENSION_create_by_OBJ(NULL, obj, crit, oct))) - goto error; + if (!(obj = OBJ_txt2obj(name, 0))) + goto error; + if (!(oct = ASN1_STRING_new())) + goto error; + if (!ASN1_STRING_set(oct, cdata, len)) + goto error; + if (!(*ud = X509_EXTENSION_create_by_OBJ(NULL, obj, crit, oct))) + goto error; - ASN1_OBJECT_free(obj); - ASN1_STRING_free(oct); + ASN1_OBJECT_free(obj); + ASN1_STRING_free(oct); - return 1; - } + return 1; + } + switch (lua_type(L, 3)) { + case LUA_TNONE: + case LUA_TNIL: + break; + case LUA_TSTRING: { if (!(conf = loadconf(L, 3))) goto error; -- cgit v1.2.3-59-g8ed1b