Skip to content

Commit b0d4d6e

Browse files
committed
Create persistent interned string for password algos
These strings are returned to userland by password_algos(), which violates thread-safety invariants. Create persistent interned strings for them instead.
1 parent 051ff33 commit b0d4d6e

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

ext/standard/password.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,8 @@
3838
static zend_array php_password_algos;
3939

4040
int php_password_algo_register(const char *ident, const php_password_algo *algo) {
41-
zval zalgo;
42-
ZVAL_PTR(&zalgo, (php_password_algo*)algo);
43-
if (zend_hash_str_add(&php_password_algos, ident, strlen(ident), &zalgo)) {
44-
return SUCCESS;
45-
}
46-
return FAILURE;
41+
zend_string *key = zend_string_init_interned(ident, strlen(ident), 1);
42+
return zend_hash_add_ptr(&php_password_algos, key, (void *) algo) ? SUCCESS : FAILURE;
4743
}
4844

4945
void php_password_algo_unregister(const char *ident) {

0 commit comments

Comments
 (0)