]> granicus.if.org Git - php/commitdiff
Fixed call to estrndup() with invalid length
authorDmitry Stogov <dmitry@php.net>
Mon, 25 Apr 2005 06:14:50 +0000 (06:14 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 25 Apr 2005 06:14:50 +0000 (06:14 +0000)
ext/standard/array.c

index 3b06a10140ec88ccb6f144a70f1b4edc8e873450..87230305132efa604608046ebf13c242258c54fb 100644 (file)
@@ -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