1
0
mirror of https://github.com/php/php-src.git synced 2026-04-05 15:12:39 +02:00

Fixed possible crash at PCRE on MSHUTDOWN

This commit is contained in:
Dmitry Stogov
2016-02-24 23:46:11 +03:00
committed by Anatol Belski
parent ecea7d3d35
commit e2bf86fbfd
4 changed files with 24 additions and 5 deletions

View File

@@ -1992,7 +1992,7 @@ static void accel_reset_pcre_cache(void)
ZEND_HASH_FOREACH_BUCKET(&PCRE_G(pcre_cache), p) {
/* Remove PCRE cache entries with inconsistent keys */
if (ZSTR_IS_INTERNED(p->key)) {
if (zend_accel_in_shm(p->key)) {
p->key = NULL;
zend_hash_del_bucket(&PCRE_G(pcre_cache), p);
}

View File

@@ -132,8 +132,13 @@ static int zend_file_cache_flock(int fd, int type)
} else { \
ZEND_ASSERT(IS_SERIALIZED(ptr)); \
(ptr) = (void*)((char*)buf + (size_t)(ptr)); \
GC_FLAGS(ptr) |= IS_STR_INTERNED; \
GC_FLAGS(ptr) &= ~IS_STR_PERMANENT; \
/* script->corrupted shows if the script in SHM or not */ \
if (EXPECTED(!script->corrupted)) { \
GC_FLAGS(ptr) |= IS_STR_INTERNED | IS_STR_PERMANENT; \
} else { \
GC_FLAGS(ptr) |= IS_STR_INTERNED; \
GC_FLAGS(ptr) &= ~IS_STR_PERMANENT; \
} \
} \
} \
} while (0)
@@ -223,8 +228,7 @@ static void *zend_file_cache_unserialize_interned(zend_string *str, int in_shm)
ret = accel_new_interned_string(str);
if (ret == str) {
/* String wasn't interned but we will use it as interned anyway */
GC_FLAGS(ret) |= IS_STR_INTERNED;
GC_FLAGS(ret) &= ~IS_STR_PERMANENT;
GC_FLAGS(ret) |= IS_STR_INTERNED | IS_STR_PERMANENT;
}
} else {
ret = str;

View File

@@ -507,3 +507,16 @@ void zend_accel_shared_protect(int mode)
}
#endif
}
int zend_accel_in_shm(void *ptr)
{
int i;
for (i = 0; i < ZSMMG(shared_segments_count); i++) {
if ((char*)ptr >= (char*)ZSMMG(shared_segments)[i]->p &&
(char*)ptr < (char*)ZSMMG(shared_segments)[i]->p + ZSMMG(shared_segments)[i]->size) {
return 1;
}
}
return 0;
}

View File

@@ -128,6 +128,8 @@ void *zend_shared_alloc(size_t size);
void *_zend_shared_memdup(void *p, size_t size, zend_bool free_source);
int zend_shared_memdup_size(void *p, size_t size);
int zend_accel_in_shm(void *ptr);
typedef union _align_test {
void *ptr;
double dbl;