Skip to content

Commit cf04707

Browse files
committed
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix bug #79643: Invalid memory read when opcache.interned_strings_buffer is 0
2 parents 5e17d88 + d134c0a commit cf04707

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2634,7 +2634,9 @@ static int zend_accel_init_shm(void)
26342634
if (ZCG(accel_directives).interned_strings_buffer) {
26352635
accel_shared_globals = zend_shared_alloc((ZCG(accel_directives).interned_strings_buffer * 1024 * 1024));
26362636
} else {
2637-
accel_shared_globals = zend_shared_alloc(sizeof(zend_accel_shared_globals));
2637+
/* Make sure there is always at least one interned string hash slot,
2638+
* so the table can be queried unconditionally. */
2639+
accel_shared_globals = zend_shared_alloc(sizeof(zend_accel_shared_globals) + sizeof(uint32_t));
26382640
}
26392641
if (!accel_shared_globals) {
26402642
zend_accel_error(ACCEL_LOG_FATAL, "Insufficient shared memory!");
@@ -2675,6 +2677,8 @@ static int zend_accel_init_shm(void)
26752677
STRTAB_INVALID_POS,
26762678
(char*)ZCSG(interned_strings).start -
26772679
((char*)&ZCSG(interned_strings) + sizeof(zend_string_table)));
2680+
} else {
2681+
*STRTAB_HASH_TO_SLOT(&ZCSG(interned_strings), 0) = STRTAB_INVALID_POS;
26782682
}
26792683

26802684
zend_interned_strings_set_request_storage_handlers(accel_new_interned_string_for_php, accel_init_interned_string_for_php);

0 commit comments

Comments
 (0)