summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerick Rethans <derick@php.net>2002-07-08 07:02:55 +0000
committerDerick Rethans <derick@php.net>2002-07-08 07:02:55 +0000
commit7faa6699153428cac938903df5e8c23f20e642a3 (patch)
tree172da7d4559aea93717eb345893ba40797335a1a
parent2afacbf1cf839674cb76162e915b3ecbd3311f91 (diff)
downloadphp-git-7faa6699153428cac938903df5e8c23f20e642a3.tar.gz
- Fix for bug #14580: Made key() binary safe
-rw-r--r--ext/standard/array.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 9c8a067732..c16271be53 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -810,6 +810,7 @@ PHP_FUNCTION(key)
{
pval **array;
char *string_key;
+ uint string_length;
ulong num_key;
HashTable *target_hash;
@@ -818,12 +819,12 @@ PHP_FUNCTION(key)
}
target_hash = HASH_OF(*array);
if (!target_hash) {
- php_error(E_WARNING, "Variable passed to key() is not an array or object");
+ php_error(E_WARNING, "%s(): Variable passed is not an array or object", get_active_function_name (TSRMLS_C));
RETURN_FALSE;
}
- switch (zend_hash_get_current_key(target_hash, &string_key, &num_key, 1)) {
+ switch (zend_hash_get_current_key_ex(target_hash, &string_key, &string_length, &num_key, 0, NULL)) {
case HASH_KEY_IS_STRING:
- RETVAL_STRING(string_key, 0);
+ RETVAL_STRINGL(string_key, string_length - 1, 1);
break;
case HASH_KEY_IS_LONG:
RETVAL_LONG(num_key);