Merge branch 'PHP-7.2'

* PHP-7.2:
  Don't keep HashTable.pDestructor in SHM and always set it into ZVAL_PTR_DTOR in zval_array_dup(). Keeping pointer to a function in SHM is not safe because of ASLR.
This commit is contained in:
Dmitry Stogov 2018-03-06 01:02:31 +03:00
commit 47f5f87826
2 changed files with 3 additions and 1 deletions

View File

@ -1831,7 +1831,7 @@ ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(HashTable *source)
GC_TYPE_INFO(target) = IS_ARRAY | (GC_COLLECTABLE << GC_FLAGS_SHIFT); GC_TYPE_INFO(target) = IS_ARRAY | (GC_COLLECTABLE << GC_FLAGS_SHIFT);
target->nTableSize = source->nTableSize; target->nTableSize = source->nTableSize;
target->pDestructor = source->pDestructor; target->pDestructor = ZVAL_PTR_DTOR;
if (source->nNumUsed == 0) { if (source->nNumUsed == 0) {
HT_FLAGS(target) = (HT_FLAGS(source) & ~(HASH_FLAG_INITIALIZED|HASH_FLAG_PACKED)) | HASH_FLAG_STATIC_KEYS; HT_FLAGS(target) = (HT_FLAGS(source) & ~(HASH_FLAG_INITIALIZED|HASH_FLAG_PACKED)) | HASH_FLAG_STATIC_KEYS;

View File

@ -89,6 +89,7 @@ static void zend_hash_persist(HashTable *ht, zend_persist_func_t pPersistElement
Bucket *p; Bucket *p;
HT_FLAGS(ht) |= HASH_FLAG_STATIC_KEYS; HT_FLAGS(ht) |= HASH_FLAG_STATIC_KEYS;
ht->pDestructor = NULL;
if (!(HT_FLAGS(ht) & HASH_FLAG_INITIALIZED)) { if (!(HT_FLAGS(ht) & HASH_FLAG_INITIALIZED)) {
HT_SET_DATA_ADDR(ht, &uninitialized_bucket); HT_SET_DATA_ADDR(ht, &uninitialized_bucket);
@ -175,6 +176,7 @@ static void zend_hash_persist_immutable(HashTable *ht)
Bucket *p; Bucket *p;
HT_FLAGS(ht) |= HASH_FLAG_STATIC_KEYS; HT_FLAGS(ht) |= HASH_FLAG_STATIC_KEYS;
ht->pDestructor = NULL;
if (!(HT_FLAGS(ht) & HASH_FLAG_INITIALIZED)) { if (!(HT_FLAGS(ht) & HASH_FLAG_INITIALIZED)) {
HT_SET_DATA_ADDR(ht, &uninitialized_bucket); HT_SET_DATA_ADDR(ht, &uninitialized_bucket);