aboutsummaryrefslogtreecommitdiff
path: root/src/crypto.h
diff options
context:
space:
mode:
authorame <[email protected]>2024-07-11 12:27:06 -0500
committerame <[email protected]>2024-07-11 12:27:06 -0500
commitc57e5e58e197fca322c2840efa435eabb62e4d9d (patch)
tree7d5bc653f6bec52494604ac8c805e311bae080f4 /src/crypto.h
parent2999d3412ccf5c7fc1a9e84695c7a2bce69d3e82 (diff)
fixes to ub:33 hashes now safe
Diffstat (limited to 'src/crypto.h')
-rw-r--r--src/crypto.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/crypto.h b/src/crypto.h
index 410b282..b3b0609 100644
--- a/src/crypto.h
+++ b/src/crypto.h
@@ -90,6 +90,12 @@ int _##luaname##_common_hash(lua_State* L){\
struct hashname##_hash* a = (struct hashname##_hash*)lua_newuserdata(L, sizeof * a);\
int ud = lua_gettop(L);\
*a = initf;\
+ int ini = lua_gettop(L);\
+ lua_newtable(L);\
+ lua_setfield(L, LUA_REGISTRYINDEX, lua_topointer(L, ud));\
+ lua_getfield(L, LUA_REGISTRYINDEX, lua_topointer(L, ud));\
+ int i;\
+ for(i = ud; i != ini; i++) luaI_tsetv(L, ini + 1, lua_topointer(L, i), i);\
lua_common_hash_meta_def(luaname);\
lua_pushvalue(L, ud);\
return 1;\
@@ -166,7 +172,7 @@ static const luaL_Reg crypto_function_list [] = {
{"base64decode",l_base64decode},
{"baseconvert",l_baseconvert},
-
+
{NULL,NULL}
};