From 9a89fb1c9dfeda4640780111f9e9437f08cfad88 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 12 Oct 2020 10:02:37 -0300 Subject: Hash always use all characters in a long string Hashes for long strings are computed only when they are used as keys in a table, not a too common case. And, in that case, it is to easy to force collisions changing only the characters which are not part of the hash. --- lstring.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lstring.h') diff --git a/lstring.h b/lstring.h index a413a9d3..450c2390 100644 --- a/lstring.h +++ b/lstring.h @@ -41,8 +41,7 @@ #define eqshrstr(a,b) check_exp((a)->tt == LUA_VSHRSTR, (a) == (b)) -LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, - unsigned int seed, size_t step); +LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts); LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); LUAI_FUNC void luaS_resize (lua_State *L, int newsize); -- cgit v1.2.3-55-g6feb