aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarLibravatar daurnimator <quae@daurnimator.com> 2017-02-27 15:24:28 +1100
committerLibravatarLibravatar daurnimator <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) {
lua_settop(L, 3);
ud = prepsimple(L, X509_EXT_CLASS);
- if (!lua_isnil(L, 3)) {
+ switch (lua_type(L, 3)) {
+ case LUA_TNONE:
+ case LUA_TNIL:
+ break;
+ case LUA_TSTRING: {
size_t len;
- const char *cdata = luaL_checklstring(L, 3, &len);
+ const char *cdata = lua_tolstring(L, 3, &len);
_Bool crit;
if (xe_new_isder(value, &crit)) {
@@ -5015,6 +5019,10 @@ static int xe_new(lua_State *L) {
ctx = &cbuf;
X509V3_set_nconf(ctx, conf);
+ break;
+ }
+ default:
+ return luaL_argerror(L, 3, "invalid extra parameter (expected string or nil)");
}
/*