Skip to content

Commit d134c0a

Browse files
twosenikic
authored andcommitted
Fix bug #79643: Invalid memory read when opcache.interned_strings_buffer is 0
1 parent 1359f79 commit d134c0a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ PHP NEWS
66
. Fixed bug #64076 (imap_sort() does not return FALSE on failure). (cmb)
77
. Fixed bug #80239 (imap_rfc822_write_address() leaks memory). (cmb)
88

9+
- Opcache:
10+
. Fixed bug #79643 (PHP with Opcache crashes when a file with specific name
11+
is included). (twosee)
12+
913
- OpenSSL:
1014
. Fixed bug #79983 (openssl_encrypt / openssl_decrypt fail with OCB mode).
1115
(Nikita)

ext/opcache/ZendAccelerator.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2576,7 +2576,9 @@ static int zend_accel_init_shm(void)
25762576
if (ZCG(accel_directives).interned_strings_buffer) {
25772577
accel_shared_globals = zend_shared_alloc((ZCG(accel_directives).interned_strings_buffer * 1024 * 1024));
25782578
} else {
2579-
accel_shared_globals = zend_shared_alloc(sizeof(zend_accel_shared_globals));
2579+
/* Make sure there is always at least one interned string hash slot,
2580+
* so the table can be queried unconditionally. */
2581+
accel_shared_globals = zend_shared_alloc(sizeof(zend_accel_shared_globals) + sizeof(uint32_t));
25802582
}
25812583
if (!accel_shared_globals) {
25822584
zend_accel_error(ACCEL_LOG_FATAL, "Insufficient shared memory!");
@@ -2617,6 +2619,8 @@ static int zend_accel_init_shm(void)
26172619
STRTAB_INVALID_POS,
26182620
(char*)ZCSG(interned_strings).start -
26192621
((char*)&ZCSG(interned_strings) + sizeof(zend_string_table)));
2622+
} else {
2623+
*STRTAB_HASH_TO_SLOT(&ZCSG(interned_strings), 0) = STRTAB_INVALID_POS;
26202624
}
26212625

26222626
zend_interned_strings_set_request_storage_handlers(accel_new_interned_string_for_php, accel_init_interned_string_for_php);

0 commit comments

Comments
 (0)