From: Dmitry Stogov Date: Mon, 25 Apr 2005 06:14:50 +0000 (+0000) Subject: Fixed call to estrndup() with invalid length X-Git-Tag: php-4.4.0RC1~103 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e3c797aed46480da42dfc1535f59586e071eefe2;p=php Fixed call to estrndup() with invalid length --- diff --git a/ext/standard/array.c b/ext/standard/array.c index 3b06a10140..8723030513 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -640,7 +640,7 @@ static int array_user_key_compare(const void *a, const void *b TSRMLS_DC) s = *((Bucket **) b); if (f->nKeyLength) { - Z_STRVAL(key1) = estrndup(f->arKey, f->nKeyLength); + Z_STRVAL(key1) = estrndup(f->arKey, f->nKeyLength-1); Z_STRLEN(key1) = f->nKeyLength-1; Z_TYPE(key1) = IS_STRING; } else { @@ -648,7 +648,7 @@ static int array_user_key_compare(const void *a, const void *b TSRMLS_DC) Z_TYPE(key1) = IS_LONG; } if (s->nKeyLength) { - Z_STRVAL(key2) = estrndup(s->arKey, s->nKeyLength); + Z_STRVAL(key2) = estrndup(s->arKey, s->nKeyLength-1); Z_STRLEN(key2) = s->nKeyLength-1; Z_TYPE(key2) = IS_STRING; } else { @@ -2492,7 +2492,7 @@ PHP_FUNCTION(array_change_key_case) zend_hash_index_update(Z_ARRVAL_P(return_value), num_key, entry, sizeof(entry), NULL); break; case HASH_KEY_IS_STRING: - new_key=estrndup(string_key,str_key_len); + new_key=estrndup(string_key,str_key_len - 1); if (change_to_upper) php_strtoupper(new_key, str_key_len - 1); else