diff --git a/.github/actions/test-alpine/action.yml b/.github/actions/test-alpine/action.yml index e14e3176b8efd..10011b06165bb 100644 --- a/.github/actions/test-alpine/action.yml +++ b/.github/actions/test-alpine/action.yml @@ -3,6 +3,9 @@ inputs: runTestsParameters: default: '' required: false + enableOpcache: + default: 'false' + required: false jitType: default: 'disable' required: false @@ -15,6 +18,7 @@ runs: export SKIP_IO_CAPTURE_TESTS=1 export STACK_LIMIT_DEFAULTS_CHECK=1 sapi/cli/php run-tests.php -P -q ${{ inputs.runTestsParameters }} \ + ${{ inputs.enableOpcache == 'true' && '-d opcache.enable_cli=1' }} \ -d opcache.jit=${{ inputs.jitType }} \ -d opcache.jit_buffer_size=64M \ -j$(nproc) \ diff --git a/.github/actions/test-linux/action.yml b/.github/actions/test-linux/action.yml index a5bf49bd00157..573358e41b5fd 100644 --- a/.github/actions/test-linux/action.yml +++ b/.github/actions/test-linux/action.yml @@ -3,6 +3,9 @@ inputs: runTestsParameters: default: '' required: false + enableOpcache: + default: 'false' + required: false jitType: default: 'disable' required: false @@ -42,6 +45,7 @@ runs: export SKIP_IO_CAPTURE_TESTS=1 export STACK_LIMIT_DEFAULTS_CHECK=1 sapi/cli/php run-tests.php -P -q ${{ inputs.runTestsParameters }} \ + ${{ inputs.enableOpcache == 'true' && '-d opcache.enable_cli=1' }} \ -d opcache.jit=${{ inputs.jitType }} \ -d opcache.protect_memory=1 \ -d opcache.jit_buffer_size=64M \ diff --git a/.github/actions/test-macos/action.yml b/.github/actions/test-macos/action.yml index e24190fef80af..958544a0b5ea4 100644 --- a/.github/actions/test-macos/action.yml +++ b/.github/actions/test-macos/action.yml @@ -3,6 +3,9 @@ inputs: runTestsParameters: default: '' required: false + enableOpcache: + default: 'false' + required: false jitType: default: 'disable' required: false @@ -16,6 +19,7 @@ runs: export CI_NO_IPV6=1 export STACK_LIMIT_DEFAULTS_CHECK=1 sapi/cli/php run-tests.php -P -q ${{ inputs.runTestsParameters }} \ + ${{ inputs.enableOpcache == 'true' && '-d opcache.enable_cli=1' }} \ -d opcache.jit=${{ inputs.jitType }} \ -d opcache.protect_memory=1 \ -d opcache.jit_buffer_size=64M \ diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index f0f93b5a40a1b..1d066ec7f9a01 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -90,10 +90,10 @@ jobs: - name: Test Tracing JIT uses: ./.github/actions/test-alpine with: + enableOpcache: true jitType: tracing runTestsParameters: >- --asan -x - -d opcache.enable_cli=1 - name: Extra tests uses: ./.github/actions/extra-tests LINUX_X64: @@ -185,33 +185,33 @@ jobs: - name: Test Tracing JIT uses: ./.github/actions/test-linux with: + enableOpcache: true jitType: tracing runTestsParameters: >- ${{ matrix.asan && '--asan' || '' }} ${{ (matrix.asan && !inputs.all_variations) && '-x' || '' }} ${{ matrix.repeat && '--repeat 2' || '' }} ${{ matrix.variation && '-d zend_test.observer.enabled=1 -d zend_test.observer.show_output=0' || '' }} - -d opcache.enable_cli=1 - name: Test OpCache if: ${{ inputs.all_variations }} uses: ./.github/actions/test-linux with: + enableOpcache: true runTestsParameters: >- ${{ matrix.asan && '--asan' || '' }} ${{ matrix.repeat && '--repeat 2' || '' }} ${{ matrix.variation && '-d zend_test.observer.enabled=1 -d zend_test.observer.show_output=0' || '' }} - -d opcache.enable_cli=1 - name: Test Function JIT # ASAN frequently timeouts. Each test run takes ~90 minutes, we can # avoid running into the 6 hour timeout by skipping the function JIT. if: ${{ inputs.all_variations && !matrix.asan }} uses: ./.github/actions/test-linux with: + enableOpcache: true jitType: function runTestsParameters: >- ${{ matrix.repeat && '--repeat 2' || '' }} ${{ matrix.variation && '-d zend_test.observer.enabled=1 -d zend_test.observer.show_output=0' || '' }} - -d opcache.enable_cli=1 - name: Extra tests uses: ./.github/actions/extra-tests - name: Verify generated files are up to date @@ -282,22 +282,19 @@ jobs: - name: Test Tracing JIT uses: ./.github/actions/test-linux with: + enableOpcache: true jitType: tracing - runTestsParameters: >- - -d opcache.enable_cli=1 - name: Test OpCache if: ${{ inputs.all_variations }} uses: ./.github/actions/test-linux with: - runTestsParameters: >- - -d opcache.enable_cli=1 + enableOpcache: true - name: Test Function JIT if: ${{ inputs.all_variations }} uses: ./.github/actions/test-linux with: + enableOpcache: true jitType: function - runTestsParameters: >- - -d opcache.enable_cli=1 - name: Extra tests uses: ./.github/actions/extra-tests MACOS: @@ -340,22 +337,19 @@ jobs: if: ${{ matrix.arch == 'X64' || !matrix.zts }} uses: ./.github/actions/test-macos with: + enableOpcache: true jitType: tracing - runTestsParameters: >- - -d opcache.enable_cli=1 - name: Test OpCache if: ${{ inputs.all_variations || (matrix.arch == 'ARM64' && matrix.zts) }} uses: ./.github/actions/test-macos with: - runTestsParameters: >- - -d opcache.enable_cli=1 + enableOpcache: true - name: Test Function JIT if: ${{ inputs.all_variations && (matrix.arch == 'X64' || !matrix.zts) }} uses: ./.github/actions/test-macos with: + enableOpcache: true jitType: function - runTestsParameters: >- - -d opcache.enable_cli=1 - name: Extra tests uses: ./.github/actions/extra-tests - name: Verify generated files are up to date @@ -411,9 +405,8 @@ jobs: - name: Test OpCache uses: ./.github/actions/test-linux with: + enableOpcache: true jitType: tracing - runTestsParameters: >- - -d opcache.enable_cli=1 - uses: codecov/codecov-action@v5 if: ${{ !cancelled() }} with: @@ -655,34 +648,34 @@ jobs: - name: Test File Cache (prime shm) uses: ./.github/actions/test-linux with: + enableOpcache: true runTestsParameters: >- - -d opcache.enable_cli=1 --file-cache-prime - name: Test File Cache (prime shm, use shm) uses: ./.github/actions/test-linux with: + enableOpcache: true runTestsParameters: >- - -d opcache.enable_cli=1 --file-cache-use - name: Test File Cache (prime shm, use file) uses: ./.github/actions/test-linux with: + enableOpcache: true runTestsParameters: >- - -d opcache.enable_cli=1 --file-cache-use -d opcache.file_cache_only=1 - name: Test File Cache Only (prime) uses: ./.github/actions/test-linux with: + enableOpcache: true runTestsParameters: >- - -d opcache.enable_cli=1 --file-cache-prime -d opcache.file_cache_only=1 - name: Test File Cache Only (use) uses: ./.github/actions/test-linux with: + enableOpcache: true runTestsParameters: >- - -d opcache.enable_cli=1 --file-cache-use -d opcache.file_cache_only=1 - name: Verify generated files are up to date @@ -769,9 +762,9 @@ jobs: - name: Test Opcache uses: ./.github/actions/test-linux with: + enableOpcache: true runTestsParameters: >- --msan - -d opcache.enable_cli=1 - name: Verify generated files are up to date uses: ./.github/actions/verify-generated-files LIBMYSQLCLIENT: diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 58558b71a5ebc..6328538241fe6 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -537,7 +537,7 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx) return fwrite(data, size, nmemb, write_handler->fp); case PHP_CURL_RETURN: if (length > 0) { - smart_str_appendl(&write_handler->buf, data, (int) length); + smart_str_appendl(&write_handler->buf, data, length); } break; case PHP_CURL_USER: { @@ -814,7 +814,7 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx) if (!Z_ISUNDEF(retval)) { _php_curl_verify_handlers(ch, /* reporterror */ true); if (Z_TYPE(retval) == IS_STRING) { - length = MIN((size * nmemb), Z_STRLEN(retval)); + length = MIN(size * nmemb, Z_STRLEN(retval)); memcpy(data, Z_STRVAL(retval), length); } else if (Z_TYPE(retval) == IS_LONG) { length = Z_LVAL_P(&retval); @@ -845,7 +845,7 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx /* Handle special case write when we're returning the entire transfer */ if (ch->handlers.write->method == PHP_CURL_RETURN && length > 0) { - smart_str_appendl(&ch->handlers.write->buf, data, (int) length); + smart_str_appendl(&ch->handlers.write->buf, data, length); } else { PHPWRITE(data, length); } diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index fd7bc6ac57e9a..9e39e2ad3e736 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -1283,8 +1283,6 @@ PHP_FUNCTION(openssl_x509_free) } /* }}} */ -/* }}} */ - /* {{{ Creates and exports a PKCS to file */ PHP_FUNCTION(openssl_pkcs12_export_to_file) { @@ -1350,6 +1348,9 @@ PHP_FUNCTION(openssl_pkcs12_export_to_file) if (args && (item = zend_hash_str_find(Z_ARRVAL_P(args), "extracerts", sizeof("extracerts")-1)) != NULL) { ca = php_openssl_array_to_X509_sk(item, 5, "extracerts"); + if (!ca) { + goto cleanup; + } } /* end parse extra config */ @@ -1443,6 +1444,9 @@ PHP_FUNCTION(openssl_pkcs12_export) if (args && (item = zend_hash_str_find(Z_ARRVAL_P(args), "extracerts", sizeof("extracerts")-1)) != NULL) { ca = php_openssl_array_to_X509_sk(item, 5, "extracerts"); + if (!ca) { + goto cleanup; + } } /* end parse extra config */ @@ -2662,7 +2666,10 @@ PHP_FUNCTION(openssl_pkcs7_encrypt) goto clean_exit; } } - sk_X509_push(recipcerts, cert); + if (sk_X509_push(recipcerts, cert) <= 0) { + X509_free(cert); + goto clean_exit; + } } ZEND_HASH_FOREACH_END(); } else { /* a single certificate */ @@ -2683,7 +2690,10 @@ PHP_FUNCTION(openssl_pkcs7_encrypt) goto clean_exit; } } - sk_X509_push(recipcerts, cert); + if (sk_X509_push(recipcerts, cert) <= 0) { + X509_free(cert); + goto clean_exit; + } } /* sanity check the cipher */ @@ -3278,7 +3288,10 @@ PHP_FUNCTION(openssl_cms_encrypt) goto clean_exit; } } - sk_X509_push(recipcerts, cert); + if (sk_X509_push(recipcerts, cert) <= 0) { + php_openssl_store_errors(); + goto clean_exit; + } } ZEND_HASH_FOREACH_END(); } else { /* a single certificate */ @@ -3298,7 +3311,10 @@ PHP_FUNCTION(openssl_cms_encrypt) goto clean_exit; } } - sk_X509_push(recipcerts, cert); + if (sk_X509_push(recipcerts, cert) <= 0) { + php_openssl_store_errors(); + goto clean_exit; + } } /* sanity check the cipher */ diff --git a/ext/openssl/openssl_backend_common.c b/ext/openssl/openssl_backend_common.c index 8895e58869b19..c0590c98acfb7 100644 --- a/ext/openssl/openssl_backend_common.c +++ b/ext/openssl/openssl_backend_common.c @@ -692,21 +692,13 @@ STACK_OF(X509) *php_openssl_load_all_certs_from_file( X509_INFO *xi; char cert_path[MAXPATHLEN]; - if(!(stack = sk_X509_new_null())) { - php_openssl_store_errors(); - php_error_docref(NULL, E_ERROR, "Memory allocation failure"); - goto end; - } - if (!php_openssl_check_path(cert_file, cert_file_len, cert_path, arg_num)) { - sk_X509_free(stack); goto end; } if (!(in = BIO_new_file(cert_path, PHP_OPENSSL_BIO_MODE_R(PKCS7_BINARY)))) { php_openssl_store_errors(); php_error_docref(NULL, E_WARNING, "Error opening the file, %s", cert_path); - sk_X509_free(stack); goto end; } @@ -714,7 +706,11 @@ STACK_OF(X509) *php_openssl_load_all_certs_from_file( if (!(sk = php_openssl_pem_read_bio_x509_info(in))) { php_openssl_store_errors(); php_error_docref(NULL, E_WARNING, "Error reading the file, %s", cert_path); - sk_X509_free(stack); + goto end; + } + + if(!(stack = sk_X509_new_reserve(NULL, sk_X509_INFO_num(sk)))) { + php_openssl_store_errors(); goto end; } @@ -886,7 +882,10 @@ STACK_OF(X509) *php_openssl_array_to_X509_sk(zval * zcerts, uint32_t arg_num, co } } - sk_X509_push(sk, cert); + if (sk_X509_push(sk, cert) <= 0) { + X509_free(cert); + goto push_fail_exit; + } } ZEND_HASH_FOREACH_END(); } else { /* a single certificate */ @@ -904,11 +903,20 @@ STACK_OF(X509) *php_openssl_array_to_X509_sk(zval * zcerts, uint32_t arg_num, co goto clean_exit; } } - sk_X509_push(sk, cert); + if (sk_X509_push(sk, cert) <= 0) { + X509_free(cert); + goto push_fail_exit; + } } clean_exit: return sk; + +push_fail_exit: + php_openssl_store_errors(); + php_openssl_sk_X509_free(sk); + sk = NULL; + goto clean_exit; } zend_result php_openssl_csr_add_subj_entry(zval *item, X509_NAME *subj, int nid) diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index d99c40bc72be5..0faf65f36437f 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -1527,6 +1527,7 @@ PHP_MINIT_FUNCTION(zend_test) memcpy(&zend_test_class_handlers, &std_object_handlers, sizeof(zend_object_handlers)); zend_test_class_handlers.get_method = zend_test_class_method_get; + zend_test_class_handlers.clone_obj = NULL; zend_test_class_handlers.free_obj = zend_test_class_free_obj; zend_test_class_handlers.offset = XtOffsetOf(zend_test_object, std);