summaryrefslogtreecommitdiff
path: root/ext/opcache/zend_file_cache.c
diff options
context:
space:
mode:
authorSammy Kaye Powers <sammyk@php.net>2020-07-16 16:31:10 -0700
committerSammy Kaye Powers <sammyk@php.net>2020-09-18 14:26:44 -0700
commit12306728c5f37dc371bc39f5fe2bf8e928368235 (patch)
treeeed1bf4671bc1c46e6a8e7a30b07bd4e9a7bc1d2 /ext/opcache/zend_file_cache.c
parent30bb15b24a266eae1577b68cd980241b1a5adf40 (diff)
downloadphp-git-12306728c5f37dc371bc39f5fe2bf8e928368235.tar.gz
Add system ID entropy API
The `zend_system_id` is a (true global) system ID that fingerprints a process state. When extensions add engine hooks during MINIT/startup, entropy is added the system ID for each hook. This allows extensions to identify that changes have been made to the engine since the last PHP process restart. Closes GH-5871
Diffstat (limited to 'ext/opcache/zend_file_cache.c')
-rw-r--r--ext/opcache/zend_file_cache.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c
index 581ef6a392..62a2d261ff 100644
--- a/ext/opcache/zend_file_cache.c
+++ b/ext/opcache/zend_file_cache.c
@@ -22,6 +22,7 @@
#include "zend_vm.h"
#include "zend_interfaces.h"
#include "zend_attributes.h"
+#include "zend_system_id.h"
#include "php.h"
#ifdef ZEND_WIN32
@@ -884,7 +885,7 @@ static void zend_file_cache_serialize(zend_persistent_script *script,
zend_persistent_script *new_script;
memcpy(info->magic, "OPCACHE", 8);
- memcpy(info->system_id, accel_system_id, 32);
+ memcpy(info->system_id, zend_system_id, 32);
info->mem_size = script->size;
info->str_size = 0;
info->script_offset = (char*)script - (char*)script->mem;
@@ -914,7 +915,7 @@ static char *zend_file_cache_get_bin_file_path(zend_string *script_path)
filename = emalloc(len + 33 + ZSTR_LEN(script_path) + sizeof(SUFFIX));
memcpy(filename, ZCG(accel_directives).file_cache, len);
filename[len] = '/';
- memcpy(filename + len + 1, accel_system_id, 32);
+ memcpy(filename + len + 1, zend_system_id, 32);
memcpy(filename + len + 33, ZSTR_VAL(script_path), ZSTR_LEN(script_path));
memcpy(filename + len + 33 + ZSTR_LEN(script_path), SUFFIX, sizeof(SUFFIX));
#else
@@ -928,7 +929,7 @@ static char *zend_file_cache_get_bin_file_path(zend_string *script_path)
len += 1 + 32;
filename[len] = '\\';
- memcpy(filename + len + 1, accel_system_id, 32);
+ memcpy(filename + len + 1, zend_system_id, 32);
if (ZSTR_LEN(script_path) >= 7 && ':' == ZSTR_VAL(script_path)[4] && '/' == ZSTR_VAL(script_path)[5] && '/' == ZSTR_VAL(script_path)[6]) {
/* phar:// or file:// */
@@ -1688,7 +1689,7 @@ zend_persistent_script *zend_file_cache_script_load(zend_file_handle *file_handl
efree(filename);
return NULL;
}
- if (memcmp(info.system_id, accel_system_id, 32) != 0) {
+ if (memcmp(info.system_id, zend_system_id, 32) != 0) {
zend_accel_error(ACCEL_LOG_WARNING, "opcache cannot read from file '%s' (wrong \"system_id\")\n", filename);
zend_file_cache_flock(fd, LOCK_UN);
close(fd);