mirror of
https://github.com/php/php-src.git
synced 2026-03-27 17:52:16 +01:00
Merge branch 'PHP-7.2'
* PHP-7.2: Include username into the file cache path
This commit is contained in:
@@ -23,6 +23,9 @@
|
||||
#include "zend_interfaces.h"
|
||||
|
||||
#include "php.h"
|
||||
#ifdef ZEND_WIN32
|
||||
#include "ext/standard/md5.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPCACHE_FILE_CACHE
|
||||
|
||||
@@ -745,16 +748,43 @@ static char *zend_file_cache_get_bin_file_path(zend_string *script_path)
|
||||
size_t len;
|
||||
char *filename;
|
||||
|
||||
#ifndef ZEND_WIN32
|
||||
len = strlen(ZCG(accel_directives).file_cache);
|
||||
filename = emalloc(len + 33 + ZSTR_LEN(script_path) + sizeof(SUFFIX));
|
||||
memcpy(filename, ZCG(accel_directives).file_cache, len);
|
||||
#ifndef ZEND_WIN32
|
||||
filename[len] = '/';
|
||||
memcpy(filename + len + 1, ZCG(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
|
||||
PHP_MD5_CTX ctx;
|
||||
char md5uname[32];
|
||||
unsigned char digest[16], c;
|
||||
size_t i;
|
||||
char *uname = php_win32_get_username();
|
||||
|
||||
PHP_MD5Init(&ctx);
|
||||
PHP_MD5Update(&ctx, uname, strlen(uname));
|
||||
PHP_MD5Final(digest, &ctx);
|
||||
for (i = 0; i < 16; i++) {
|
||||
c = digest[i] >> 4;
|
||||
c = (c <= 9) ? c + '0' : c - 10 + 'a';
|
||||
md5uname[i * 2] = c;
|
||||
c = digest[i] & 0x0f;
|
||||
c = (c <= 9) ? c + '0' : c - 10 + 'a';
|
||||
md5uname[(i * 2) + 1] = c;
|
||||
}
|
||||
|
||||
len = strlen(ZCG(accel_directives).file_cache);
|
||||
|
||||
filename = emalloc(len + 33 + 33 + ZSTR_LEN(script_path) + sizeof(SUFFIX));
|
||||
|
||||
memcpy(filename, ZCG(accel_directives).file_cache, len);
|
||||
filename[len] = '\\';
|
||||
memcpy(filename + 1 + len, md5uname, 32);
|
||||
len += 32;
|
||||
filename[len] = '\\';
|
||||
|
||||
memcpy(filename + len + 1, ZCG(system_id), 32);
|
||||
if (ZSTR_LEN(script_path) >= 2 && ':' == ZSTR_VAL(script_path)[1]) {
|
||||
/* local fs */
|
||||
@@ -767,6 +797,7 @@ static char *zend_file_cache_get_bin_file_path(zend_string *script_path)
|
||||
memcpy(filename + len + 33, ZSTR_VAL(script_path), ZSTR_LEN(script_path));
|
||||
memcpy(filename + len + 33 + ZSTR_LEN(script_path), SUFFIX, sizeof(SUFFIX));
|
||||
}
|
||||
free(uname);
|
||||
#endif
|
||||
|
||||
return filename;
|
||||
|
||||
Reference in New Issue
Block a user