Expected behaviour
get_random_bytes() should be called once random has initialized it's fd global to -1.
Actual behaviour
phpredis calls get_random_bytes() before random_globals_ctor() is called resulting in the fd remaining 0. This breaks systems that rely on it (those without a getrandom() syscall) as an uninitialised fd is expected to be less than 0 (see line 156 in random.c).
I'm seeing this behaviour on
- OS: CentOS Linux release 7.9.2009
- Redis: 5.0.4
- PHP: 7.4.21
- phpredis: 5.3.2
Steps to reproduce, backtrace or example script
PHP's internals call GINIT functions before MINIT which describes the behaviour seen here (stepping through the process confirms this).
I've checked
phpredis should call get_random_bytes() in it's MINIT to prevent this problem.
Expected behaviour
get_random_bytes()should be called once random has initialized it'sfdglobal to -1.Actual behaviour
phpredis calls
get_random_bytes()beforerandom_globals_ctor()is called resulting in thefdremaining 0. This breaks systems that rely on it (those without agetrandom()syscall) as an uninitialisedfdis expected to be less than 0 (see line 156 in random.c).I'm seeing this behaviour on
Steps to reproduce, backtrace or example script
PHP's internals call GINIT functions before MINIT which describes the behaviour seen here (stepping through the process confirms this).
I've checked
developbranchphpredis should call
get_random_bytes()in it's MINIT to prevent this problem.