summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-02-27 15:24:28 +1100
committerdaurnimator <quae@daurnimator.com>2017-02-27 15:35:10 +1100
commit25337767bfb8d8d40c142e4acc6bc11116b15266 (patch)
treed5e44bf68d87460cc3dba8cf3ba4e8c648a6b307
parent3d7180c36adb6b9be8f4bb9825d3e35eef146bf5 (diff)
downloadluaossl-25337767bfb8d8d40c142e4acc6bc11116b15266.tar.gz
luaossl-25337767bfb8d8d40c142e4acc6bc11116b15266.tar.bz2
luaossl-25337767bfb8d8d40c142e4acc6bc11116b15266.zip
extension.new: Swap to switch/case based argument checking
-rw-r--r--src/openssl.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/openssl.c b/src/openssl.c
index 900b909..9ea9469 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -4989,9 +4989,13 @@ static int xe_new(lua_State *L) {
4989 lua_settop(L, 3); 4989 lua_settop(L, 3);
4990 ud = prepsimple(L, X509_EXT_CLASS); 4990 ud = prepsimple(L, X509_EXT_CLASS);
4991 4991
4992 if (!lua_isnil(L, 3)) { 4992 switch (lua_type(L, 3)) {
4993 case LUA_TNONE:
4994 case LUA_TNIL:
4995 break;
4996 case LUA_TSTRING: {
4993 size_t len; 4997 size_t len;
4994 const char *cdata = luaL_checklstring(L, 3, &len); 4998 const char *cdata = lua_tolstring(L, 3, &len);
4995 _Bool crit; 4999 _Bool crit;
4996 5000
4997 if (xe_new_isder(value, &crit)) { 5001 if (xe_new_isder(value, &crit)) {
@@ -5015,6 +5019,10 @@ static int xe_new(lua_State *L) {
5015 5019
5016 ctx = &cbuf; 5020 ctx = &cbuf;
5017 X509V3_set_nconf(ctx, conf); 5021 X509V3_set_nconf(ctx, conf);
5022 break;
5023 }
5024 default:
5025 return luaL_argerror(L, 3, "invalid extra parameter (expected string or nil)");
5018 } 5026 }
5019 5027
5020 /* 5028 /*