Sitelet https://github.com/phpredis/phpredis/issues/1987
Skip to content

phpredis calls php_random_bytes before random is initialised #1987

Description

@Novynn

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

  • There is no similar issue from other users
  • Issue isn't fixed in develop branch

phpredis should call get_random_bytes() in it's MINIT to prevent this problem.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions