From d39dbdee24d05e23183dafdfb06982777ef6f934 Mon Sep 17 00:00:00 2001 From: Arpad Ray Date: Fri, 11 Nov 2011 14:42:18 +0000 Subject: [PATCH] Fix hash key length in register/remove_user_shutdown_function --- ext/session/session.c | 6 +++--- ext/standard/basic_functions.c | 8 ++++---- ext/standard/basic_functions.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/session/session.c b/ext/session/session.c index faa45824aa..6f1ce401f8 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -1638,7 +1638,7 @@ static PHP_FUNCTION(session_set_save_handler) shutdown_function_entry.arguments[0] = callback; /* add shutdown function, removing the old one if it exists */ - if (!register_user_shutdown_function("session_shutdown", &shutdown_function_entry TSRMLS_CC)) { + if (!register_user_shutdown_function("session_shutdown", sizeof("session_shutdown"), &shutdown_function_entry TSRMLS_CC)) { zval_ptr_dtor(&callback); efree(shutdown_function_entry.arguments); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to register session shutdown function"); @@ -1646,7 +1646,7 @@ static PHP_FUNCTION(session_set_save_handler) } } else { /* remove shutdown function */ - remove_user_shutdown_function("session_shutdown" TSRMLS_CC); + remove_user_shutdown_function("session_shutdown", sizeof("session_shutdown") TSRMLS_CC); } if (PS(mod) && PS(session_status) == php_session_none && PS(mod) != &ps_mod_user) { @@ -1661,7 +1661,7 @@ static PHP_FUNCTION(session_set_save_handler) } /* remove shutdown function */ - remove_user_shutdown_function("session_shutdown" TSRMLS_CC); + remove_user_shutdown_function("session_shutdown", sizeof("session_shutdown") TSRMLS_CC); for (i = 0; i < 6; i++) { if (!zend_is_callable(*args[i], 0, &name TSRMLS_CC)) { diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 2e3f54d31a..e16d6bd9d5 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -5081,21 +5081,21 @@ PHP_FUNCTION(register_shutdown_function) } /* }}} */ -PHPAPI zend_bool register_user_shutdown_function(char *function_name, php_shutdown_function_entry *shutdown_function_entry TSRMLS_DC) /* {{{ */ +PHPAPI zend_bool register_user_shutdown_function(char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry TSRMLS_DC) /* {{{ */ { if (!BG(user_shutdown_function_names)) { ALLOC_HASHTABLE(BG(user_shutdown_function_names)); zend_hash_init(BG(user_shutdown_function_names), 0, NULL, (void (*)(void *)) user_shutdown_function_dtor, 0); } - return zend_hash_update(BG(user_shutdown_function_names), function_name, sizeof(function_name), shutdown_function_entry, sizeof(php_shutdown_function_entry), NULL) != FAILURE; + return zend_hash_update(BG(user_shutdown_function_names), function_name, function_len, shutdown_function_entry, sizeof(php_shutdown_function_entry), NULL) != FAILURE; } /* }}} */ -PHPAPI zend_bool remove_user_shutdown_function(char *function_name TSRMLS_DC) /* {{{ */ +PHPAPI zend_bool remove_user_shutdown_function(char *function_name, size_t function_len TSRMLS_DC) /* {{{ */ { if (BG(user_shutdown_function_names)) { - return zend_hash_del_key_or_index(BG(user_shutdown_function_names), function_name, sizeof(function_name), 0, HASH_DEL_KEY) != FAILURE; + return zend_hash_del_key_or_index(BG(user_shutdown_function_names), function_name, function_len, 0, HASH_DEL_KEY) != FAILURE; } return 0; diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h index e7c66e6cf6..2232ed7d4d 100644 --- a/ext/standard/basic_functions.h +++ b/ext/standard/basic_functions.h @@ -257,8 +257,8 @@ typedef struct _php_shutdown_function_entry { int arg_count; } php_shutdown_function_entry; -PHPAPI extern zend_bool register_user_shutdown_function(char *function_name, php_shutdown_function_entry *shutdown_function_entry TSRMLS_DC); -PHPAPI extern zend_bool remove_user_shutdown_function(char *function_name TSRMLS_DC); +PHPAPI extern zend_bool register_user_shutdown_function(char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry TSRMLS_DC); +PHPAPI extern zend_bool remove_user_shutdown_function(char *function_name, size_t function_len TSRMLS_DC); PHPAPI extern zend_bool append_user_shutdown_function(php_shutdown_function_entry shutdown_function_entry TSRMLS_DC); #endif /* BASIC_FUNCTIONS_H */ -- 2.40.0