diff options
| author | ame <[email protected]> | 2024-07-11 12:27:06 -0500 |
|---|---|---|
| committer | ame <[email protected]> | 2024-07-11 12:27:06 -0500 |
| commit | 027c7a7622a4aa4d0ed6483ba495ab91e0c68991 (patch) | |
| tree | 7d5bc653f6bec52494604ac8c805e311bae080f4 /src/crypto.h | |
| parent | 90a2acc2f0c9d3904e1dea737e45ef6b10f96a22 (diff) | |
fixes to ub:33 hashes now safe
Diffstat (limited to 'src/crypto.h')
| -rw-r--r-- | src/crypto.h | 8 |
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}
};
|
