diff options
author | twosee <twose@qq.com> | 2020-06-09 14:55:36 +0800 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-10-20 12:50:28 +0200 |
commit | d134c0ac05b6f8969463ff1cf5dd7b6332bf5ab4 (patch) | |
tree | d0d268e57757890be4a3c6f19568aa508f76860e /ext/opcache/ZendAccelerator.c | |
parent | 1359f793ee2de31122697fda4ec0503a0d055170 (diff) | |
download | php-git-d134c0ac05b6f8969463ff1cf5dd7b6332bf5ab4.tar.gz |
Fix bug #79643: Invalid memory read when opcache.interned_strings_buffer is 0
Diffstat (limited to 'ext/opcache/ZendAccelerator.c')
-rw-r--r-- | ext/opcache/ZendAccelerator.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 3da1a5492e..21dba385da 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -2576,7 +2576,9 @@ static int zend_accel_init_shm(void) if (ZCG(accel_directives).interned_strings_buffer) { accel_shared_globals = zend_shared_alloc((ZCG(accel_directives).interned_strings_buffer * 1024 * 1024)); } else { - accel_shared_globals = zend_shared_alloc(sizeof(zend_accel_shared_globals)); + /* Make sure there is always at least one interned string hash slot, + * so the table can be queried unconditionally. */ + accel_shared_globals = zend_shared_alloc(sizeof(zend_accel_shared_globals) + sizeof(uint32_t)); } if (!accel_shared_globals) { zend_accel_error(ACCEL_LOG_FATAL, "Insufficient shared memory!"); @@ -2617,6 +2619,8 @@ static int zend_accel_init_shm(void) STRTAB_INVALID_POS, (char*)ZCSG(interned_strings).start - ((char*)&ZCSG(interned_strings) + sizeof(zend_string_table))); + } else { + *STRTAB_HASH_TO_SLOT(&ZCSG(interned_strings), 0) = STRTAB_INVALID_POS; } zend_interned_strings_set_request_storage_handlers(accel_new_interned_string_for_php, accel_init_interned_string_for_php); |