summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/openssl.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/openssl.c b/src/openssl.c
index ed7222e..4564061 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -772,8 +772,9 @@ NOTUSED static auxtype_t auxL_getref(lua_State *L, auxref_t ref) {
772static int auxL_testoption(lua_State *L, int index, const char *def, const char *const *optlist, _Bool nocase) { 772static int auxL_testoption(lua_State *L, int index, const char *def, const char *const *optlist, _Bool nocase) {
773 const char *optname = (def)? luaL_optstring(L, index, def) : luaL_checkstring(L, index); 773 const char *optname = (def)? luaL_optstring(L, index, def) : luaL_checkstring(L, index);
774 int (*optcmp)() = (nocase)? &strcasecmp : &strcmp; 774 int (*optcmp)() = (nocase)? &strcasecmp : &strcmp;
775 int i;
775 776
776 for (int i = 0; optlist[i]; i++) { 777 for (i = 0; optlist[i]; i++) {
777 if (0 == optcmp(optlist[i], optname)) 778 if (0 == optcmp(optlist[i], optname))
778 return i; 779 return i;
779 } 780 }
@@ -929,9 +930,11 @@ static inline size_t auxL_liblen(const auxL_Reg *l) {
929 930
930static void auxL_setfuncs(lua_State *L, const auxL_Reg *l, int nups) { 931static void auxL_setfuncs(lua_State *L, const auxL_Reg *l, int nups) {
931 for (; l->name; l++) { 932 for (; l->name; l++) {
933 int i;
934
932 /* copy shared upvalues */ 935 /* copy shared upvalues */
933 luaL_checkstack(L, nups, "too many upvalues"); 936 luaL_checkstack(L, nups, "too many upvalues");
934 for (int i = 0; i < nups; i++) 937 for (i = 0; i < nups; i++)
935 lua_pushvalue(L, -nups); 938 lua_pushvalue(L, -nups);
936 939
937 /* nil-fill local upvalues */ 940 /* nil-fill local upvalues */
@@ -3741,13 +3744,15 @@ static int pk_getParameters(lua_State *L) {
3741 return luaL_error(L, "%d: unsupported EVP_PKEY base type", base_type); 3744 return luaL_error(L, "%d: unsupported EVP_PKEY base type", base_type);
3742 3745
3743 if (lua_isnoneornil(L, 2)) { 3746 if (lua_isnoneornil(L, 2)) {
3747 const char *const *optname;
3748
3744 /* 3749 /*
3745 * Use special "{" parameter to tell loop to push table. 3750 * Use special "{" parameter to tell loop to push table.
3746 * Subsequent parameters will be assigned as fields. 3751 * Subsequent parameters will be assigned as fields.
3747 */ 3752 */
3748 lua_pushstring(L, "{"); 3753 lua_pushstring(L, "{");
3749 luaL_checkstack(L, nopts, "too many arguments"); 3754 luaL_checkstack(L, nopts, "too many arguments");
3750 for (const char *const *optname = optlist; *optname; optname++) { 3755 for (optname = optlist; *optname; optname++) {
3751 lua_pushstring(L, *optname); 3756 lua_pushstring(L, *optname);
3752 } 3757 }
3753 } 3758 }
@@ -3927,11 +3932,12 @@ static const auxL_Reg pk_globals[] = {
3927}; 3932};
3928 3933
3929static void pk_luainit(lua_State *L, _Bool reset) { 3934static void pk_luainit(lua_State *L, _Bool reset) {
3935 char **k;
3930 if (!auxL_newmetatable(L, PKEY_CLASS, reset)) 3936 if (!auxL_newmetatable(L, PKEY_CLASS, reset))
3931 return; 3937 return;
3932 auxL_setfuncs(L, pk_metatable, 0); 3938 auxL_setfuncs(L, pk_metatable, 0);
3933 auxL_newlib(L, pk_methods, 0); 3939 auxL_newlib(L, pk_methods, 0);
3934 for (char **k = (char *[]){ "__index", "__newindex", 0 }; *k; k++) { 3940 for (k = (char *[]){ "__index", "__newindex", 0 }; *k; k++) {
3935 lua_getfield(L, -2, *k); /* closure */ 3941 lua_getfield(L, -2, *k); /* closure */
3936 lua_pushvalue(L, -2); /* method table */ 3942 lua_pushvalue(L, -2); /* method table */
3937 lua_setupvalue(L, -2, 1); 3943 lua_setupvalue(L, -2, 1);