lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Thu, Nov 24, 2022 at 3:38 AM bil til <> wrote:
sorry about another Lua beginner "internals question".

I am just looking at my time functions, and I recognized that timer(0)
is invoked at some times in Lua to create a randomization seed.

I changed the code of my timer() function now, so that I am sure a
real random seed is given there (my microcontroller has a Random
Number Generator on board for this purpose), but I do not really see
any changes.

The random seed produced by luai_makeseed is used to make the hash function that is used for strings unpredictable. The implementation of strings relies on this hash to produce nicely distributed values, and without some randomization an attacker could easily produce thousands of strings that all hash to the same value, which would cause very slow behavior for instance when they're used as table keys.