From 559879d75e091768bcce982d8b511c93bb2cfaef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Tue, 18 May 2021 17:27:31 +0200 Subject: [PATCH] Remove randominess from spl_object_hash --- ext/spl/php_spl.c | 17 +---------------- ext/spl/php_spl.h | 3 --- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 6aedca9882669..b3dfebc623bca 100644 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -657,18 +657,7 @@ PHP_FUNCTION(spl_object_id) PHPAPI zend_string *php_spl_object_hash(zend_object *obj) /* {{{*/ { - intptr_t hash_handle, hash_handlers; - - if (!SPL_G(hash_mask_init)) { - SPL_G(hash_mask_handle) = (intptr_t)(php_mt_rand() >> 1); - SPL_G(hash_mask_handlers) = (intptr_t)(php_mt_rand() >> 1); - SPL_G(hash_mask_init) = 1; - } - - hash_handle = SPL_G(hash_mask_handle)^(intptr_t)obj->handle; - hash_handlers = SPL_G(hash_mask_handlers); - - return strpprintf(32, "%016zx%016zx", hash_handle, hash_handlers); + return strpprintf(32, "%016zx0000000000000000", (intptr_t)obj->handle); } /* }}} */ @@ -736,7 +725,6 @@ PHP_RINIT_FUNCTION(spl) /* {{{ */ { SPL_G(autoload_extensions) = NULL; SPL_G(autoload_functions) = NULL; - SPL_G(hash_mask_init) = 0; return SUCCESS; } /* }}} */ @@ -751,9 +739,6 @@ PHP_RSHUTDOWN_FUNCTION(spl) /* {{{ */ FREE_HASHTABLE(SPL_G(autoload_functions)); SPL_G(autoload_functions) = NULL; } - if (SPL_G(hash_mask_init)) { - SPL_G(hash_mask_init) = 0; - } return SUCCESS; } /* }}} */ diff --git a/ext/spl/php_spl.h b/ext/spl/php_spl.h index 9f87ca30b8d87..8110b74cc2279 100644 --- a/ext/spl/php_spl.h +++ b/ext/spl/php_spl.h @@ -54,9 +54,6 @@ PHP_MINFO_FUNCTION(spl); ZEND_BEGIN_MODULE_GLOBALS(spl) zend_string *autoload_extensions; HashTable *autoload_functions; - intptr_t hash_mask_handle; - intptr_t hash_mask_handlers; - int hash_mask_init; ZEND_END_MODULE_GLOBALS(spl) ZEND_EXTERN_MODULE_GLOBALS(spl)