]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.0' into PHP-7.1
authorStanislav Malyshev <stas@php.net>
Fri, 25 Nov 2016 23:32:59 +0000 (15:32 -0800)
committerStanislav Malyshev <stas@php.net>
Fri, 25 Nov 2016 23:32:59 +0000 (15:32 -0800)
* PHP-7.0:
  Fix more size_t/int implicit conversions

1  2 
ext/phar/phar_object.c

index 28ec8a3411efd1f3940b55399f3fa2c0e791866e,fc31a7e536b56804304abaf53c8a9d89abd14333..ca9a031d36f4448378da7b0c042e12ece6e48e11
@@@ -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 (alias_len == phar_obj->archive->alias_len && memcmp(phar_obj->archive->alias, alias, alias_len) == 0) {
+               if (ZEND_SIZE_T_INT_OVFL(alias_len)) {
+                       RETURN_FALSE;
+               }
 +              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;