Skip to content

Commit 559879d

Browse files
committed
Remove randominess from spl_object_hash
1 parent 11648c0 commit 559879d

File tree

2 files changed

+1
-19
lines changed

2 files changed

+1
-19
lines changed

ext/spl/php_spl.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -657,18 +657,7 @@ PHP_FUNCTION(spl_object_id)
657657

658658
PHPAPI zend_string *php_spl_object_hash(zend_object *obj) /* {{{*/
659659
{
660-
intptr_t hash_handle, hash_handlers;
661-
662-
if (!SPL_G(hash_mask_init)) {
663-
SPL_G(hash_mask_handle) = (intptr_t)(php_mt_rand() >> 1);
664-
SPL_G(hash_mask_handlers) = (intptr_t)(php_mt_rand() >> 1);
665-
SPL_G(hash_mask_init) = 1;
666-
}
667-
668-
hash_handle = SPL_G(hash_mask_handle)^(intptr_t)obj->handle;
669-
hash_handlers = SPL_G(hash_mask_handlers);
670-
671-
return strpprintf(32, "%016zx%016zx", hash_handle, hash_handlers);
660+
return strpprintf(32, "%016zx0000000000000000", (intptr_t)obj->handle);
672661
}
673662
/* }}} */
674663

@@ -736,7 +725,6 @@ PHP_RINIT_FUNCTION(spl) /* {{{ */
736725
{
737726
SPL_G(autoload_extensions) = NULL;
738727
SPL_G(autoload_functions) = NULL;
739-
SPL_G(hash_mask_init) = 0;
740728
return SUCCESS;
741729
} /* }}} */
742730

@@ -751,9 +739,6 @@ PHP_RSHUTDOWN_FUNCTION(spl) /* {{{ */
751739
FREE_HASHTABLE(SPL_G(autoload_functions));
752740
SPL_G(autoload_functions) = NULL;
753741
}
754-
if (SPL_G(hash_mask_init)) {
755-
SPL_G(hash_mask_init) = 0;
756-
}
757742
return SUCCESS;
758743
} /* }}} */
759744

ext/spl/php_spl.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ PHP_MINFO_FUNCTION(spl);
5454
ZEND_BEGIN_MODULE_GLOBALS(spl)
5555
zend_string *autoload_extensions;
5656
HashTable *autoload_functions;
57-
intptr_t hash_mask_handle;
58-
intptr_t hash_mask_handlers;
59-
int hash_mask_init;
6057
ZEND_END_MODULE_GLOBALS(spl)
6158

6259
ZEND_EXTERN_MODULE_GLOBALS(spl)

0 commit comments

Comments
 (0)