Fix hash key length in register/remove_user_shutdown_function

This commit is contained in:
Arpad Ray 2011-11-11 14:42:18 +00:00
parent 9103413981
commit d39dbdee24
3 changed files with 9 additions and 9 deletions

View File

@ -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)) {

View File

@ -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;

View File

@ -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 */