Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ PHP NEWS
AF_INET* family only. (David Carlier)
. Fixed GH-20532 (socket_addrinfo_lookup gives the error code with a new
optional parameter). (David Carlier)
. Added AF_PACKET support completion for socket_sendto()/socket_recvfrom().
(David Carlier)

- Sodium:
. Added support for libsodium 1.0.21 IPcrypt and XOF APIs. (jedisct1)
Expand Down
2 changes: 2 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ PHP 8.6 INTERNALS UPGRADE NOTES
. The zval_dtor() alias of zval_ptr_dtor_nogc() has been removed.
Call zval_ptr_dtor_nogc() directly instead.
. The internal zend_copy_parameters_array() function is no longer exposed.
. The internal zend_hash_minmax() function is no longer exposed. Scan the
HashTable directly and use zend_compare() for value comparisons instead.
. The zend_make_callable() function has been removed, if a callable zval
needs to be obtained use the zend_get_callable_zval_from_fcc() function
instead. If this was used to store a callable, then an FCC should be
Expand Down
67 changes: 0 additions & 67 deletions Zend/zend_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -3238,73 +3238,6 @@ ZEND_API int zend_hash_compare(HashTable *ht1, const HashTable *ht2, compare_fun
}


ZEND_API zval* ZEND_FASTCALL zend_hash_minmax(const HashTable *ht, compare_func_t compar, uint32_t flag)
{
uint32_t idx;
zval *res;

IS_CONSISTENT(ht);

if (ht->nNumOfElements == 0 ) {
return NULL;
}

if (HT_IS_PACKED(ht)) {
zval *zv;

idx = 0;
while (1) {
if (idx == ht->nNumUsed) {
return NULL;
}
if (Z_TYPE(ht->arPacked[idx]) != IS_UNDEF) break;
idx++;
}
res = ht->arPacked + idx;
for (; idx < ht->nNumUsed; idx++) {
zv = ht->arPacked + idx;
if (UNEXPECTED(Z_TYPE_P(zv) == IS_UNDEF)) continue;

if (flag) {
if (compar(res, zv) < 0) { /* max */
res = zv;
}
} else {
if (compar(res, zv) > 0) { /* min */
res = zv;
}
}
}
} else {
Bucket *p;

idx = 0;
while (1) {
if (idx == ht->nNumUsed) {
return NULL;
}
if (Z_TYPE(ht->arData[idx].val) != IS_UNDEF) break;
idx++;
}
res = &ht->arData[idx].val;
for (; idx < ht->nNumUsed; idx++) {
p = ht->arData + idx;
if (UNEXPECTED(Z_TYPE(p->val) == IS_UNDEF)) continue;

if (flag) {
if (compar(res, &p->val) < 0) { /* max */
res = &p->val;
}
} else {
if (compar(res, &p->val) > 0) { /* min */
res = &p->val;
}
}
}
}
return res;
}

ZEND_API bool ZEND_FASTCALL _zend_handle_numeric_str_ex(const char *key, size_t length, zend_ulong *idx)
{
const char *tmp = key;
Expand Down
1 change: 0 additions & 1 deletion Zend/zend_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ typedef int (*bucket_compare_func_t)(Bucket *a, Bucket *b);
ZEND_API int zend_hash_compare(HashTable *ht1, const HashTable *ht2, compare_func_t compar, bool ordered);
ZEND_API void ZEND_FASTCALL zend_hash_sort_ex(HashTable *ht, sort_func_t sort_func, bucket_compare_func_t compare_func, bool renumber);
ZEND_API void ZEND_FASTCALL zend_array_sort_ex(HashTable *ht, sort_func_t sort_func, bucket_compare_func_t compare_func, bool renumber);
ZEND_API zval* ZEND_FASTCALL zend_hash_minmax(const HashTable *ht, compare_func_t compar, uint32_t flag);

static zend_always_inline void ZEND_FASTCALL zend_hash_sort(HashTable *ht, bucket_compare_func_t compare_func, bool renumber) {
zend_hash_sort_ex(ht, zend_sort, compare_func, renumber);
Expand Down
20 changes: 10 additions & 10 deletions ext/hash/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ static void php_hash_do_hash(
}
php_stream_close(stream);
if (n < 0) {
efree(context);
php_hash_free_context(ops, context);
RETURN_FALSE;
}
} else {
Expand All @@ -395,7 +395,7 @@ static void php_hash_do_hash(

digest = zend_string_alloc(ops->digest_size, 0);
ops->hash_final((unsigned char *) ZSTR_VAL(digest), context);
efree(context);
php_hash_free_context(ops, context);

if (raw_output) {
ZSTR_VAL(digest)[ops->digest_size] = 0;
Expand Down Expand Up @@ -534,7 +534,7 @@ static void php_hash_do_hash_hmac(
}
php_stream_close(stream);
if (n < 0) {
efree(context);
php_hash_free_context(ops, context);
efree(K);
zend_string_efree(digest);
RETURN_FALSE;
Expand All @@ -552,7 +552,7 @@ static void php_hash_do_hash_hmac(
/* Zero the key */
ZEND_SECURE_ZERO(K, ops->block_size);
efree(K);
efree(context);
php_hash_free_context(ops, context);

if (raw_output) {
ZSTR_VAL(digest)[ops->digest_size] = 0;
Expand Down Expand Up @@ -813,7 +813,7 @@ PHP_FUNCTION(hash_final)
ZSTR_VAL(digest)[digest_len] = 0;

/* Invalidate the object from further use */
efree(hash->context);
php_hash_free_context(hash->ops, hash->context);
hash->context = NULL;

if (raw_output) {
Expand Down Expand Up @@ -967,7 +967,7 @@ PHP_FUNCTION(hash_hkdf)
ZEND_SECURE_ZERO(digest, ops->digest_size);
ZEND_SECURE_ZERO(prk, ops->digest_size);
efree(K);
efree(context);
php_hash_free_context(ops, context);
efree(prk);
efree(digest);
ZSTR_VAL(returnval)[length] = 0;
Expand Down Expand Up @@ -1083,7 +1083,7 @@ PHP_FUNCTION(hash_pbkdf2)
efree(K1);
efree(K2);
efree(computed_salt);
efree(context);
php_hash_free_context(ops, context);
efree(digest);
efree(temp);

Expand Down Expand Up @@ -1348,7 +1348,7 @@ PHP_FUNCTION(mhash_keygen_s2k)
RETVAL_STRINGL(key, bytes);
ZEND_SECURE_ZERO(key, bytes);
efree(digest);
efree(context);
php_hash_free_context(ops, context);
efree(key);
}
}
Expand Down Expand Up @@ -1378,7 +1378,7 @@ static void php_hashcontext_dtor(zend_object *obj) {
php_hashcontext_object *hash = php_hashcontext_from_object(obj);

if (hash->context) {
efree(hash->context);
php_hash_free_context(hash->ops, hash->context);
hash->context = NULL;
}

Expand Down Expand Up @@ -1414,7 +1414,7 @@ static zend_object *php_hashcontext_clone(zend_object *zobj) {
newobj->ops->hash_init(newobj->context, NULL);

if (SUCCESS != newobj->ops->hash_copy(newobj->ops, oldobj->context, newobj->context)) {
efree(newobj->context);
php_hash_free_context(newobj->ops, newobj->context);
newobj->context = NULL;
return znew;
}
Expand Down
1 change: 1 addition & 0 deletions ext/hash/hash_adler32.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ const php_hash_ops php_hash_adler32_ops = {
4, /* what to say here? */
4,
sizeof(PHP_ADLER32_CTX),
0,
0
};
3 changes: 3 additions & 0 deletions ext/hash/hash_crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const php_hash_ops php_hash_crc32_ops = {
4, /* what to say here? */
4,
sizeof(PHP_CRC32_CTX),
0,
0
};

Expand All @@ -115,6 +116,7 @@ const php_hash_ops php_hash_crc32b_ops = {
4, /* what to say here? */
4,
sizeof(PHP_CRC32_CTX),
0,
0
};

Expand All @@ -130,5 +132,6 @@ const php_hash_ops php_hash_crc32c_ops = {
4, /* what to say here? */
4,
sizeof(PHP_CRC32_CTX),
0,
0
};
4 changes: 4 additions & 0 deletions ext/hash/hash_fnv.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const php_hash_ops php_hash_fnv132_ops = {
4,
4,
sizeof(PHP_FNV132_CTX),
0,
0
};

Expand All @@ -45,6 +46,7 @@ const php_hash_ops php_hash_fnv1a32_ops = {
4,
4,
sizeof(PHP_FNV132_CTX),
0,
0
};

Expand All @@ -60,6 +62,7 @@ const php_hash_ops php_hash_fnv164_ops = {
8,
4,
sizeof(PHP_FNV164_CTX),
0,
0
};

Expand All @@ -75,6 +78,7 @@ const php_hash_ops php_hash_fnv1a64_ops = {
8,
4,
sizeof(PHP_FNV164_CTX),
0,
0
};

Expand Down
6 changes: 4 additions & 2 deletions ext/hash/hash_gost.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ const php_hash_ops php_hash_gost_ops = {
32,
32,
sizeof(PHP_GOST_CTX),
1
1,
0
};

const php_hash_ops php_hash_gost_crypto_ops = {
Expand All @@ -342,5 +343,6 @@ const php_hash_ops php_hash_gost_crypto_ops = {
32,
32,
sizeof(PHP_GOST_CTX),
1
1,
0
};
2 changes: 1 addition & 1 deletion ext/hash/hash_haval.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ const php_hash_ops php_hash_##p##haval##b##_ops = { \
php_hash_serialize, \
php_hash_unserialize, \
PHP_HAVAL_SPEC, \
((b) / 8), 128, sizeof(PHP_HAVAL_CTX), 1 }; \
((b) / 8), 128, sizeof(PHP_HAVAL_CTX), 1, 0 }; \
PHP_HASH_API void PHP_##p##HAVAL##b##Init(PHP_HAVAL_CTX *context, ZEND_ATTRIBUTE_UNUSED HashTable *args) \
{ int i; context->count[0] = context->count[1] = 0; \
for(i = 0; i < 8; i++) context->state[i] = D0[i]; \
Expand Down
1 change: 1 addition & 0 deletions ext/hash/hash_joaat.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const php_hash_ops php_hash_joaat_ops = {
4,
4,
sizeof(PHP_JOAAT_CTX),
0,
0
};

Expand Down
9 changes: 6 additions & 3 deletions ext/hash/hash_md.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const php_hash_ops php_hash_md5_ops = {
16,
64,
sizeof(PHP_MD5_CTX),
1
1,
0
};

const php_hash_ops php_hash_md4_ops = {
Expand All @@ -42,7 +43,8 @@ const php_hash_ops php_hash_md4_ops = {
16,
64,
sizeof(PHP_MD4_CTX),
1
1,
0
};

static hash_spec_result php_md2_unserialize(php_hashcontext_object *hash, zend_long magic, const zval *zv);
Expand All @@ -59,7 +61,8 @@ const php_hash_ops php_hash_md2_ops = {
16,
16,
sizeof(PHP_MD2_CTX),
1
1,
0
};

/* MD common stuff */
Expand Down
3 changes: 3 additions & 0 deletions ext/hash/hash_murmur.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const php_hash_ops php_hash_murmur3a_ops = {
4,
4,
sizeof(PHP_MURMUR3A_CTX),
0,
0
};

Expand Down Expand Up @@ -93,6 +94,7 @@ const php_hash_ops php_hash_murmur3c_ops = {
16,
4,
sizeof(PHP_MURMUR3C_CTX),
0,
0
};

Expand Down Expand Up @@ -172,6 +174,7 @@ const php_hash_ops php_hash_murmur3f_ops = {
16,
8,
sizeof(PHP_MURMUR3F_CTX),
0,
0
};

Expand Down
12 changes: 8 additions & 4 deletions ext/hash/hash_ripemd.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const php_hash_ops php_hash_ripemd128_ops = {
16,
64,
sizeof(PHP_RIPEMD128_CTX),
1
1,
0
};

const php_hash_ops php_hash_ripemd160_ops = {
Expand All @@ -46,7 +47,8 @@ const php_hash_ops php_hash_ripemd160_ops = {
20,
64,
sizeof(PHP_RIPEMD160_CTX),
1
1,
0
};

const php_hash_ops php_hash_ripemd256_ops = {
Expand All @@ -61,7 +63,8 @@ const php_hash_ops php_hash_ripemd256_ops = {
32,
64,
sizeof(PHP_RIPEMD256_CTX),
1
1,
0
};

const php_hash_ops php_hash_ripemd320_ops = {
Expand All @@ -76,7 +79,8 @@ const php_hash_ops php_hash_ripemd320_ops = {
40,
64,
sizeof(PHP_RIPEMD320_CTX),
1
1,
0
};

/* {{{ PHP_RIPEMD128Init
Expand Down
Loading