php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
zend_system_id.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Authors: Sammy Kaye Powers <sammyk@php.net> |
14 | Dmitry Stogov <dmitry@php.net> |
15 +----------------------------------------------------------------------+
16 */
17
18#include "php.h"
19#include "zend_system_id.h"
20#include "zend_extensions.h"
21#include "ext/standard/md5.h"
22#include "ext/hash/php_hash.h"
23
25
26static PHP_MD5_CTX context;
27static int finalized = 0;
28
29ZEND_API zend_result zend_add_system_entropy(const char *module_name, const char *hook_name, const void *data, size_t size)
30{
31 if (finalized == 0) {
32 PHP_MD5Update(&context, module_name, strlen(module_name));
33 PHP_MD5Update(&context, hook_name, strlen(hook_name));
34 if (size) {
36 }
37 return SUCCESS;
38 }
39 return FAILURE;
40}
41
42#define ZEND_BIN_ID "BIN_" ZEND_TOSTR(SIZEOF_INT) ZEND_TOSTR(SIZEOF_LONG) ZEND_TOSTR(SIZEOF_SIZE_T) ZEND_TOSTR(SIZEOF_ZEND_LONG) ZEND_TOSTR(ZEND_MM_ALIGNMENT)
43
45{
50 if (strstr(PHP_VERSION, "-dev") != 0) {
51 /* Development versions may be changed from build to build */
52 PHP_MD5Update(&context, __DATE__, sizeof(__DATE__)-1);
53 PHP_MD5Update(&context, __TIME__, sizeof(__TIME__)-1);
54 }
55 zend_system_id[0] = '\0';
56}
57
58#define ZEND_HOOK_AST_PROCESS (1 << 0)
59#define ZEND_HOOK_COMPILE_FILE (1 << 1)
60#define ZEND_HOOK_EXECUTE_EX (1 << 2)
61#define ZEND_HOOK_EXECUTE_INTERNAL (1 << 3)
62#define ZEND_HOOK_INTERRUPT_FUNCTION (1 << 4)
63
65{
66 unsigned char digest[16];
67 uint8_t hooks = 0;
68
69 if (zend_ast_process) {
70 hooks |= ZEND_HOOK_AST_PROCESS;
71 }
74 }
76 hooks |= ZEND_HOOK_EXECUTE_EX;
77 }
80 }
83 }
84 PHP_MD5Update(&context, &hooks, sizeof hooks);
85
86 for (int16_t i = 0; i < 256; i++) {
87 if (zend_get_user_opcode_handler((uint8_t) i) != NULL) {
88 PHP_MD5Update(&context, &i, sizeof i);
89 }
90 }
91
92 PHP_MD5Final(digest, &context);
93 php_hash_bin2hex(zend_system_id, digest, sizeof digest);
94 finalized = 1;
95}
strstr(string $haystack, string $needle, bool $before_needle=false)
new_type size
Definition ffi.c:4365
#define NULL
Definition gdcache.h:45
#define SUCCESS
Definition hash_sha3.c:261
PHPAPI void PHP_MD5Final(unsigned char *result, PHP_MD5_CTX *ctx)
Definition md5.c:339
PHPAPI void PHP_MD5Update(PHP_MD5_CTX *ctx, const void *data, size_t size)
Definition md5.c:304
#define PHP_MD5Init(ctx)
Definition md5.h:43
#define PHP_VERSION
Definition php_version.h:7
zend_op_array *(* compile_file)(zend_file_handle *file_handle, int type)
Definition phpdbg.h:272
zend_constant * data
Definition dce.c:49
ZEND_API void(* zend_interrupt_function)(zend_execute_data *execute_data)
Definition zend.c:89
ZEND_API zend_ast_process_t zend_ast_process
Definition zend_ast.c:29
strlen(string $string)
ZEND_API zend_op_array *(* zend_compile_file)(zend_file_handle *file_handle, int type)
#define ZEND_API
ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode)
ZEND_API void(* zend_execute_ex)(zend_execute_data *execute_data)
ZEND_API void(* zend_execute_internal)(zend_execute_data *execute_data, zval *return_value)
ZEND_API void execute_ex(zend_execute_data *execute_data)
#define ZEND_EXTENSION_BUILD_ID
#define ZEND_HOOK_COMPILE_FILE
void zend_startup_system_id(void)
#define ZEND_BIN_ID
#define ZEND_HOOK_AST_PROCESS
ZEND_API zend_result zend_add_system_entropy(const char *module_name, const char *hook_name, const void *data, size_t size)
#define ZEND_HOOK_EXECUTE_EX
void zend_finalize_system_id(void)
ZEND_API char zend_system_id[32]
#define ZEND_HOOK_EXECUTE_INTERNAL
#define ZEND_HOOK_INTERRUPT_FUNCTION
@ FAILURE
Definition zend_types.h:61
ZEND_RESULT_CODE zend_result
Definition zend_types.h:64