Randomness added to table length computation
A bad actor could fill only a few entries in a table (power of twos in decreasing order, see tests) and produce a small table with a huge length. If your program builds a table with external data and iterates over its length, this behavior could be an issue.
This commit is contained in:
2
lvm.c
2
lvm.c
@@ -722,7 +722,7 @@ void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) {
|
||||
Table *h = hvalue(rb);
|
||||
tm = fasttm(L, h->metatable, TM_LEN);
|
||||
if (tm) break; /* metamethod? break switch to call it */
|
||||
setivalue(s2v(ra), l_castU2S(luaH_getn(h))); /* else primitive len */
|
||||
setivalue(s2v(ra), l_castU2S(luaH_getn(L, h))); /* else primitive len */
|
||||
return;
|
||||
}
|
||||
case LUA_VSHRSTR: {
|
||||
|
||||
Reference in New Issue
Block a user