summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2014-06-17 02:59:00 +0400
committerDmitry Stogov <dmitry@zend.com>2014-06-17 02:59:00 +0400
commitaccaaf9d6e15e57a64a054d7b5ebc0998ee510a4 (patch)
tree2eef5afc7e827bba05327f1e50f7ae73e61ffa3d /ext
parenta8e63d2b566841f915f9f61c22f76af4857b258a (diff)
downloadphp-git-accaaf9d6e15e57a64a054d7b5ebc0998ee510a4.tar.gz
Don't include trailing zero into hash function
Diffstat (limited to 'ext')
-rw-r--r--ext/opcache/ZendAccelerator.c46
-rw-r--r--ext/opcache/zend_accelerator_module.c4
2 files changed, 25 insertions, 25 deletions
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index 37e0b3b361..426156fa5b 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -213,13 +213,13 @@ static ZEND_INI_MH(accel_include_path_on_modify)
if (ZCG(enabled) && accel_startup_ok &&
(ZCG(counted) || ZCSG(accelerator_enabled))) {
- ZCG(include_path_key) = zend_accel_hash_find(&ZCSG(include_paths), ZCG(include_path), ZCG(include_path_len) + 1);
+ ZCG(include_path_key) = zend_accel_hash_find(&ZCSG(include_paths), ZCG(include_path), ZCG(include_path_len));
if (!ZCG(include_path_key) &&
!zend_accel_hash_is_full(&ZCSG(include_paths))) {
SHM_UNPROTECT();
zend_shared_alloc_lock(TSRMLS_C);
- ZCG(include_path_key) = zend_accel_hash_find(&ZCSG(include_paths), ZCG(include_path), ZCG(include_path_len) + 1);
+ ZCG(include_path_key) = zend_accel_hash_find(&ZCSG(include_paths), ZCG(include_path), ZCG(include_path_len));
if (!ZCG(include_path_key) &&
!zend_accel_hash_is_full(&ZCSG(include_paths))) {
char *key;
@@ -229,7 +229,7 @@ static ZEND_INI_MH(accel_include_path_on_modify)
memcpy(key, ZCG(include_path), ZCG(include_path_len) + 1);
key[ZCG(include_path_len) + 1] = 'A' + ZCSG(include_paths).num_entries;
ZCG(include_path_key) = key + ZCG(include_path_len) + 1;
- zend_accel_hash_update(&ZCSG(include_paths), key, ZCG(include_path_len) + 1, 0, ZCG(include_path_key));
+ zend_accel_hash_update(&ZCSG(include_paths), key, ZCG(include_path_len), 0, ZCG(include_path_key));
} else {
zend_accel_schedule_restart_if_necessary(ACCEL_RESTART_OOM TSRMLS_CC);
}
@@ -960,13 +960,13 @@ char *accel_make_persistent_key_ex(zend_file_handle *file_handle, int path_lengt
if (ZCG(include_path_check) &&
ZCG(enabled) && accel_startup_ok &&
(ZCG(counted) || ZCSG(accelerator_enabled)) &&
- !zend_accel_hash_find(&ZCSG(include_paths), ZCG(include_path), ZCG(include_path_len) + 1) &&
+ !zend_accel_hash_find(&ZCSG(include_paths), ZCG(include_path), ZCG(include_path_len)) &&
!zend_accel_hash_is_full(&ZCSG(include_paths))) {
SHM_UNPROTECT();
zend_shared_alloc_lock(TSRMLS_C);
- ZCG(include_path_key) = zend_accel_hash_find(&ZCSG(include_paths), ZCG(include_path), ZCG(include_path_len) + 1);
+ ZCG(include_path_key) = zend_accel_hash_find(&ZCSG(include_paths), ZCG(include_path), ZCG(include_path_len));
if (ZCG(include_path_key)) {
include_path = ZCG(include_path_key);
include_path_len = 1;
@@ -978,7 +978,7 @@ char *accel_make_persistent_key_ex(zend_file_handle *file_handle, int path_lengt
memcpy(key, ZCG(include_path), ZCG(include_path_len) + 1);
key[ZCG(include_path_len) + 1] = 'A' + ZCSG(include_paths).num_entries;
ZCG(include_path_key) = key + ZCG(include_path_len) + 1;
- zend_accel_hash_update(&ZCSG(include_paths), key, ZCG(include_path_len) + 1, 0, ZCG(include_path_key));
+ zend_accel_hash_update(&ZCSG(include_paths), key, ZCG(include_path_len), 0, ZCG(include_path_key));
include_path = ZCG(include_path_key);
include_path_len = 1;
} else {
@@ -1073,7 +1073,7 @@ int zend_accel_invalidate(const char *filename, int filename_len, zend_bool forc
return FAILURE;
}
- persistent_script = zend_accel_hash_find(&ZCSG(hash), realpath, strlen(realpath) + 1);
+ persistent_script = zend_accel_hash_find(&ZCSG(hash), realpath, strlen(realpath));
if (persistent_script && !persistent_script->corrupted) {
zend_file_handle file_handle;
@@ -1110,7 +1110,7 @@ int zend_accel_invalidate(const char *filename, int filename_len, zend_bool forc
/* Adds another key for existing cached script */
static void zend_accel_add_key(char *key, unsigned int key_length, zend_accel_hash_entry *bucket TSRMLS_DC)
{
- if (!zend_accel_hash_find(&ZCSG(hash), key, key_length + 1)) {
+ if (!zend_accel_hash_find(&ZCSG(hash), key, key_length)) {
if (zend_accel_hash_is_full(&ZCSG(hash))) {
zend_accel_error(ACCEL_LOG_DEBUG, "No more entries in hash table!");
ZSMMG(memory_exhausted) = 1;
@@ -1119,7 +1119,7 @@ static void zend_accel_add_key(char *key, unsigned int key_length, zend_accel_ha
char *new_key = zend_shared_alloc(key_length + 1);
if (new_key) {
memcpy(new_key, key, key_length + 1);
- if (zend_accel_hash_update(&ZCSG(hash), new_key, key_length + 1, 1, bucket)) {
+ if (zend_accel_hash_update(&ZCSG(hash), new_key, key_length, 1, bucket)) {
zend_accel_error(ACCEL_LOG_INFO, "Added key '%s'", new_key);
}
} else {
@@ -1161,7 +1161,7 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
/* Check if we still need to put the file into the cache (may be it was
* already stored by another process. This final check is done under
* exclusive lock) */
- bucket = zend_accel_hash_find_entry(&ZCSG(hash), new_persistent_script->full_path->val, new_persistent_script->full_path->len + 1);
+ bucket = zend_accel_hash_find_entry(&ZCSG(hash), new_persistent_script->full_path->val, new_persistent_script->full_path->len);
if (bucket) {
zend_persistent_script *existing_persistent_script = (zend_persistent_script *)bucket->data;
@@ -1208,7 +1208,7 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
new_persistent_script->dynamic_members.checksum = zend_accel_script_checksum(new_persistent_script);
/* store script structure in the hash table */
- bucket = zend_accel_hash_update(&ZCSG(hash), new_persistent_script->full_path->val, new_persistent_script->full_path->len + 1, 0, new_persistent_script);
+ bucket = zend_accel_hash_update(&ZCSG(hash), new_persistent_script->full_path->val, new_persistent_script->full_path->len, 0, new_persistent_script);
if (bucket) {
zend_accel_error(ACCEL_LOG_INFO, "Cached script '%s'", new_persistent_script->full_path);
if (!ZCG(accel_directives).revalidate_path &&
@@ -1217,7 +1217,7 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
(new_persistent_script->full_path->len != key_length ||
memcmp(new_persistent_script->full_path->val, key, key_length) != 0)) {
/* link key to the same persistent script in hash table */
- if (zend_accel_hash_update(&ZCSG(hash), key, key_length + 1, 1, bucket)) {
+ if (zend_accel_hash_update(&ZCSG(hash), key, key_length, 1, bucket)) {
zend_accel_error(ACCEL_LOG_INFO, "Added key '%s'", key);
} else {
zend_accel_error(ACCEL_LOG_DEBUG, "No more entries in hash table!");
@@ -1545,7 +1545,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type T
if ((key = accel_make_persistent_key(file_handle, &key_length TSRMLS_CC)) == NULL) {
return accelerator_orig_compile_file(file_handle, type TSRMLS_CC);
}
- persistent_script = zend_accel_hash_find(&ZCSG(hash), key, key_length + 1);
+ persistent_script = zend_accel_hash_find(&ZCSG(hash), key, key_length);
if (!persistent_script) {
/* try to find cached script by full real path */
zend_accel_hash_entry *bucket;
@@ -1575,7 +1575,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type T
}
if (file_handle->opened_path &&
- (bucket = zend_accel_hash_find_entry(&ZCSG(hash), file_handle->opened_path, strlen(file_handle->opened_path) + 1)) != NULL) {
+ (bucket = zend_accel_hash_find_entry(&ZCSG(hash), file_handle->opened_path, strlen(file_handle->opened_path))) != NULL) {
persistent_script = (zend_persistent_script *)bucket->data;
if (!ZCG(accel_directives).revalidate_path &&
@@ -1868,7 +1868,7 @@ static int persistent_stream_open_function(const char *filename, zend_file_handl
/* Check if requested file already cached (by full name) */
if (IS_ABSOLUTE_PATH(filename, filename_len) &&
- (persistent_script = zend_accel_hash_find(&ZCSG(hash), (char*)filename, filename_len + 1)) != NULL &&
+ (persistent_script = zend_accel_hash_find(&ZCSG(hash), (char*)filename, filename_len)) != NULL &&
!persistent_script->corrupted) {
handle->opened_path = estrndup(persistent_script->full_path, persistent_script->full_path_len);
@@ -1884,7 +1884,7 @@ static int persistent_stream_open_function(const char *filename, zend_file_handl
key = accel_make_persistent_key_ex(handle, filename_len, &key_length TSRMLS_CC);
if (!ZCG(accel_directives).revalidate_path &&
key &&
- (persistent_script = zend_accel_hash_find(&ZCSG(hash), key, key_length + 1)) != NULL &&
+ (persistent_script = zend_accel_hash_find(&ZCSG(hash), key, key_length)) != NULL &&
!persistent_script->corrupted) {
handle->opened_path = estrndup(persistent_script->full_path, persistent_script->full_path_len);
@@ -1899,7 +1899,7 @@ static int persistent_stream_open_function(const char *filename, zend_file_handl
/* Check if requested file already cached (by real name) */
if (resolved_path &&
- (bucket = zend_accel_hash_find_entry(&ZCSG(hash), resolved_path, strlen(resolved_path) + 1)) != NULL) {
+ (bucket = zend_accel_hash_find_entry(&ZCSG(hash), resolved_path, strlen(resolved_path))) != NULL) {
persistent_script = (zend_persistent_script *)bucket->data;
if (persistent_script && !persistent_script->corrupted) {
@@ -1976,7 +1976,7 @@ static int persistent_stream_open_function(const char *filename, zend_file_handl
if ((IS_ABSOLUTE_PATH(filename, filename_len) ||
is_stream_path(filename)) &&
- (persistent_script = zend_accel_hash_find(&ZCSG(hash), (char*)filename, filename_len + 1)) != NULL &&
+ (persistent_script = zend_accel_hash_find(&ZCSG(hash), (char*)filename, filename_len)) != NULL &&
!persistent_script->corrupted) {
handle->opened_path = estrndup(persistent_script->full_path, persistent_script->full_path_len);
@@ -2029,7 +2029,7 @@ static char* persistent_zend_resolve_path(const char *filename, int filename_len
/* Check if requested file already cached (by full name) */
if ((IS_ABSOLUTE_PATH(filename, filename_len) ||
is_stream_path(filename)) &&
- (bucket = zend_accel_hash_find_entry(&ZCSG(hash), (char*)filename, filename_len + 1)) != NULL) {
+ (bucket = zend_accel_hash_find_entry(&ZCSG(hash), (char*)filename, filename_len)) != NULL) {
persistent_script = (zend_persistent_script *)bucket->data;
if (persistent_script && !persistent_script->corrupted) {
memcpy(ZCG(key), persistent_script->full_path->val, persistent_script->full_path->len + 1);
@@ -2047,7 +2047,7 @@ static char* persistent_zend_resolve_path(const char *filename, int filename_len
key = accel_make_persistent_key_ex(&handle, filename_len, &key_length TSRMLS_CC);
if (!ZCG(accel_directives).revalidate_path &&
key &&
- (persistent_script = zend_accel_hash_find(&ZCSG(hash), key, key_length + 1)) != NULL &&
+ (persistent_script = zend_accel_hash_find(&ZCSG(hash), key, key_length)) != NULL &&
!persistent_script->corrupted) {
/* we have persistent script */
@@ -2061,7 +2061,7 @@ static char* persistent_zend_resolve_path(const char *filename, int filename_len
/* Check if requested file already cached (by real path) */
if (resolved_path &&
- (bucket = zend_accel_hash_find_entry(&ZCSG(hash), resolved_path, strlen(resolved_path) + 1)) != NULL) {
+ (bucket = zend_accel_hash_find_entry(&ZCSG(hash), resolved_path, strlen(resolved_path))) != NULL) {
persistent_script = (zend_persistent_script *)bucket->data;
if (persistent_script && !persistent_script->corrupted) {
@@ -2675,7 +2675,7 @@ static int accel_startup(zend_extension *extension)
ZCG(include_path_key) = NULL;
if (ZCG(include_path) && *ZCG(include_path)) {
ZCG(include_path_len) = strlen(ZCG(include_path));
- ZCG(include_path_key) = zend_accel_hash_find(&ZCSG(include_paths), ZCG(include_path), ZCG(include_path_len) + 1);
+ ZCG(include_path_key) = zend_accel_hash_find(&ZCSG(include_paths), ZCG(include_path), ZCG(include_path_len));
if (!ZCG(include_path_key) &&
!zend_accel_hash_is_full(&ZCSG(include_paths))) {
char *key;
@@ -2686,7 +2686,7 @@ static int accel_startup(zend_extension *extension)
memcpy(key, ZCG(include_path), ZCG(include_path_len) + 1);
key[ZCG(include_path_len) + 1] = 'A' + ZCSG(include_paths).num_entries;
ZCG(include_path_key) = key + ZCG(include_path_len) + 1;
- zend_accel_hash_update(&ZCSG(include_paths), key, ZCG(include_path_len) + 1, 0, ZCG(include_path_key));
+ zend_accel_hash_update(&ZCSG(include_paths), key, ZCG(include_path_len), 0, ZCG(include_path_key));
} else {
zend_accel_schedule_restart_if_necessary(ACCEL_RESTART_OOM TSRMLS_CC);
}
diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c
index 7ed055e9c6..7c0383e0c3 100644
--- a/ext/opcache/zend_accelerator_module.c
+++ b/ext/opcache/zend_accelerator_module.c
@@ -318,7 +318,7 @@ static int filename_is_in_cache(char *filename, int filename_len TSRMLS_DC)
handle.type = ZEND_HANDLE_FILENAME;
if (IS_ABSOLUTE_PATH(filename, filename_len)) {
- persistent_script = zend_accel_hash_find(&ZCSG(hash), filename, filename_len + 1);
+ persistent_script = zend_accel_hash_find(&ZCSG(hash), filename, filename_len);
if (persistent_script) {
return !persistent_script->corrupted &&
validate_timestamp_and_record(persistent_script, &handle TSRMLS_CC) == SUCCESS;
@@ -326,7 +326,7 @@ static int filename_is_in_cache(char *filename, int filename_len TSRMLS_DC)
}
if ((key = accel_make_persistent_key_ex(&handle, filename_len, &key_length TSRMLS_CC)) != NULL) {
- persistent_script = zend_accel_hash_find(&ZCSG(hash), key, key_length + 1);
+ persistent_script = zend_accel_hash_find(&ZCSG(hash), key, key_length);
return persistent_script && !persistent_script->corrupted &&
validate_timestamp_and_record(persistent_script, &handle TSRMLS_CC) == SUCCESS;
}