From: Stanislav Malyshev Date: Fri, 25 Nov 2016 23:32:59 +0000 (-0800) Subject: Merge branch 'PHP-7.0' into PHP-7.1 X-Git-Tag: php-7.1.1RC1~189 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f9a80a0a2922a585e8d11e36a318128050121bcd;p=php Merge branch 'PHP-7.0' into PHP-7.1 * PHP-7.0: Fix more size_t/int implicit conversions --- f9a80a0a2922a585e8d11e36a318128050121bcd diff --cc ext/phar/phar_object.c index 28ec8a3411,fc31a7e536..ca9a031d36 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@@ -1321,10 -1356,10 +1346,10 @@@ PHP_METHOD(Phar, unlinkArchive } zname = (char*)zend_get_executed_filename(); - zname_len = strlen(zname); + zname_len = (int)strlen(zname); if (zname_len > 7 && !memcmp(zname, "phar://", 7) && SUCCESS == phar_split_fname(zname, zname_len, &arch, &arch_len, &entry, &entry_len, 2, 0)) { - if (arch_len == fname_len && !memcmp(arch, fname, arch_len)) { + if ((size_t)arch_len == fname_len && !memcmp(arch, fname, arch_len)) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar archive \"%s\" cannot be unlinked from within itself", fname); efree(arch); efree(entry); @@@ -2664,7 -2743,10 +2716,10 @@@ PHP_METHOD(Phar, setAlias } if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &alias, &alias_len) == SUCCESS) { + if (ZEND_SIZE_T_INT_OVFL(alias_len)) { + RETURN_FALSE; + } - if (alias_len == phar_obj->archive->alias_len && memcmp(phar_obj->archive->alias, alias, alias_len) == 0) { + if (alias_len == (size_t)phar_obj->archive->alias_len && memcmp(phar_obj->archive->alias, alias, alias_len) == 0) { RETURN_TRUE; } if (alias_len && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len))) { @@@ -3776,7 -3880,17 +3853,10 @@@ PHP_METHOD(Phar, addFile if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } + if (ZEND_SIZE_T_INT_OVFL(fname_len)) { + RETURN_FALSE; + } -#if PHP_API_VERSION < 20100412 - if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) { - zend_throw_exception_ex(spl_ce_RuntimeException, 0, "phar error: unable to open file \"%s\" to add to phar archive, safe_mode restrictions prevent this", fname); - return; - } -#endif - if (!strstr(fname, "://") && php_check_open_basedir(fname)) { zend_throw_exception_ex(spl_ce_RuntimeException, 0, "phar error: unable to open file \"%s\" to add to phar archive, open_basedir restrictions prevent this", fname); return;