Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cea48b4
openssl: Propagate PHP_OPENSSL_ASN1_INTEGER_set() failure
ndossche Mar 7, 2026
35e8cb8
Fix memory leaks when php_openssl_dh_pub_from_priv() fails
ndossche Jan 28, 2026
ebaaa7d
Merge branch 'PHP-8.4' into PHP-8.5
ndossche Apr 4, 2026
1fa8c0f
Merge branch 'PHP-8.5'
ndossche Apr 4, 2026
f9519cc
[ci skip] Silence test warning
ndossche Apr 4, 2026
e6e4d05
Merge branch 'PHP-8.4' into PHP-8.5
ndossche Apr 4, 2026
0ef031f
Merge branch 'PHP-8.5'
ndossche Apr 4, 2026
4cffcba
Add missing error check on BN_CTX_new()
ndossche Jan 28, 2026
7eb38cd
Fix memory leaks when BN_bin2bn() fails
ndossche Jan 28, 2026
2467dfb
Fix UB and error propagation when X509_gmtime_adj() fails
ndossche Jan 27, 2026
f81a9a2
Add missing error check on SSL_set_ex_data()
ndossche Jan 27, 2026
3199500
Merge branch 'PHP-8.4' into PHP-8.5
ndossche Apr 4, 2026
1b7449f
Merge branch 'PHP-8.5'
ndossche Apr 4, 2026
4e105e0
Fix openssl compile warnings on Solaris
iluuu1994 Apr 4, 2026
883014d
Fix const-generic warning in xp_ssl.c
ndossche Apr 4, 2026
a28d33f
Merge branch 'PHP-8.4' into PHP-8.5
ndossche Apr 4, 2026
43f3245
Merge branch 'PHP-8.5'
ndossche Apr 4, 2026
79b1ca2
Fix memory leaks and missing error propagation when php_openssl_csr_m…
ndossche Jan 25, 2026
2c8de71
Merge branch 'PHP-8.4' into PHP-8.5
ndossche Apr 4, 2026
ff098c7
Merge branch 'PHP-8.5'
ndossche Apr 4, 2026
c5fb035
openssl: Fix merge
ndossche Apr 4, 2026
e6f46d4
Merge branch 'PHP-8.4' into PHP-8.5
ndossche Apr 4, 2026
e166dc8
Merge branch 'PHP-8.5'
ndossche Apr 4, 2026
7cc45e0
Windows: Allow OpenSSL Argon2 password hashing on ZTS (#21194)
petk Apr 4, 2026
f907571
ext/intl: Add spoofchecker files unconditionally on Windows (#21621)
petk Apr 4, 2026
2b74894
More gcov improvements
iluuu1994 Apr 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Zend/zend_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,13 @@ static zend_always_inline bool zend_char_has_nul_byte(const char *s, size_t know
#define RETURN_ZVAL(zv, copy, dtor) do { RETVAL_ZVAL(zv, copy, dtor); return; } while (0)
#define RETURN_FALSE do { RETVAL_FALSE; return; } while (0)
#define RETURN_TRUE do { RETVAL_TRUE; return; } while (0)
#define RETURN_THROWS() do { ZEND_ASSERT(EG(exception)); (void) return_value; return; } while (0)

#ifndef HAVE_GCOV
# define RETURN_THROWS() do { ZEND_ASSERT(EG(exception)); (void) return_value; return; } while (0)
#else
/* Drop ZEND_ASSERT() to avoid untested branch warning in gcov. */
# define RETURN_THROWS() do { (void) return_value; return; } while (0)
#endif

#define HASH_OF(p) (Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties(Z_OBJ_P(p)) : NULL)))

Expand Down
11 changes: 8 additions & 3 deletions build/Makefile.gcov
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ GCOVR_EXCLUDES = \
'ext/hash/sha3/.*' \
'ext/lexbor/lexbor/.*' \
'ext/mbstring/libmbfl/.*' \
'ext/opcache/jit/ir/.*' \
'ext/pcre/pcre2lib/.*' \
'ext/uri/uriparser/.*'

GCOVR_EXCLUDE_LINES_BY_PATTERN = '.*\b(ZEND_PARSE_PARAMETERS_(START|END|NONE)|Z_PARAM_).*'
GCOVR_EXCLUDE_LINES_BY_PATTERNS = \
'.*\b(ZEND_PARSE_PARAMETERS_(START|END|NONE)|Z_PARAM_).*' \
'\s*EMPTY_SWITCH_DEFAULT_CASE\(\)(;)?\s*' \
'\s*ZEND_ASSERT\(.*\);\s*' \
'\s*ZEND_UNREACHABLE\(\);\s*'

lcov: lcov-html

Expand All @@ -53,14 +58,14 @@ gcovr-html:
@rm -rf gcovr_html/
@mkdir gcovr_html
gcovr -sr . -o gcovr_html/index.html --html --html-details \
--exclude-lines-by-pattern $(GCOVR_EXCLUDE_LINES_BY_PATTERN) \
$(foreach pattern, $(GCOVR_EXCLUDE_LINES_BY_PATTERNS), --exclude-lines-by-pattern $(pattern)) \
$(foreach lib, $(GCOVR_EXCLUDES), -e $(lib))

gcovr-xml:
@echo "Generating gcovr XML"
@rm -f gcovr.xml
gcovr -sr . -o gcovr.xml --xml \
--exclude-lines-by-pattern $(GCOVR_EXCLUDE_LINES_BY_PATTERN) \
$(foreach pattern, $(GCOVR_EXCLUDE_LINES_BY_PATTERNS), --exclude-lines-by-pattern $(pattern)) \
$(foreach lib, $(GCOVR_EXCLUDES), -e $(lib))

.PHONY: gcovr-html lcov-html php_lcov.info
12 changes: 5 additions & 7 deletions ext/intl/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,11 @@ if (PHP_INTL != "no") {
resourcebundle_iterator.cpp",
"intl");

if (CHECK_HEADER("unicode/uspoof.h", "CFLAGS_INTL")) {
ADD_SOURCES(configure_module_dirname + "/spoofchecker", "\
spoofchecker_class.cpp \
spoofchecker_create.cpp \
spoofchecker_main.cpp",
"intl");
}
ADD_SOURCES(configure_module_dirname + "/spoofchecker", "\
spoofchecker_class.cpp \
spoofchecker_create.cpp \
spoofchecker_main.cpp",
"intl");

ADD_SOURCES(configure_module_dirname + "/transliterator", "\
transliterator_class.cpp \
Expand Down
4 changes: 1 addition & 3 deletions ext/openssl/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ if (PHP_OPENSSL != "no") {
AC_DEFINE("LOAD_OPENSSL_LEGACY_PROVIDER", 1, "Define to 1 to load the OpenSSL legacy algorithm provider in addition to the default provider.");
}
if (PHP_OPENSSL_ARGON2 != "no") {
if (PHP_ZTS != "no") {
WARNING("OpenSSL argon2 hashing not supported in ZTS mode for now");
} else if (!GREP_HEADER("openssl/thread.h", "OSSL_set_max_threads", PHP_PHP_BUILD + "\\include")) {
if (!GREP_HEADER("openssl/thread.h", "OSSL_set_max_threads", PHP_PHP_BUILD + "\\include")) {
WARNING("OpenSSL argon2 hashing requires OpenSSL >= 3.2");
} else {
AC_DEFINE("HAVE_OPENSSL_ARGON2", 1, "Define to 1 to enable OpenSSL argon2 password hashing.");
Expand Down
23 changes: 15 additions & 8 deletions ext/openssl/openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,7 @@ PHP_FUNCTION(openssl_pkcs12_read)
add_index_zval(&zextracerts, i, &zextracert);
}

BIO_reset(bio_out);
(void)BIO_reset(bio_out);
X509_free(aCA);
}
BIO_free(bio_out);
Expand Down Expand Up @@ -1815,7 +1815,11 @@ PHP_FUNCTION(openssl_csr_sign)
goto cleanup;
}
} else {
PHP_OPENSSL_ASN1_INTEGER_set(X509_get_serialNumber(new_cert), serial);
if (!PHP_OPENSSL_ASN1_INTEGER_set(X509_get_serialNumber(new_cert), serial)) {
php_openssl_store_errors();
php_error_docref(NULL, E_WARNING, "Error setting serial number");
goto cleanup;
}
}

if (!X509_set_subject_name(new_cert, X509_REQ_get_subject_name(csr))) {
Expand All @@ -1830,8 +1834,11 @@ PHP_FUNCTION(openssl_csr_sign)
php_openssl_store_errors();
goto cleanup;
}
X509_gmtime_adj(X509_getm_notBefore(new_cert), 0);
X509_gmtime_adj(X509_getm_notAfter(new_cert), 60*60*24*num_days);
if (!X509_gmtime_adj(X509_getm_notBefore(new_cert), 0)
|| !X509_gmtime_adj(X509_getm_notAfter(new_cert), 60*60*24*num_days)) {
php_openssl_store_errors();
goto cleanup;
}
i = X509_set_pubkey(new_cert, key);
if (!i) {
php_openssl_store_errors();
Expand Down Expand Up @@ -2837,7 +2844,7 @@ PHP_FUNCTION(openssl_pkcs7_read)
ZVAL_STRINGL(&zcert, bio_buf->data, bio_buf->length);
add_index_zval(zout, i, &zcert);
}
BIO_reset(bio_out);
(void)BIO_reset(bio_out);
}
BIO_free(bio_out);
}
Expand All @@ -2856,7 +2863,7 @@ PHP_FUNCTION(openssl_pkcs7_read)
ZVAL_STRINGL(&zcert, bio_buf->data, bio_buf->length);
add_index_zval(zout, i, &zcert);
}
BIO_reset(bio_out);
(void)BIO_reset(bio_out);
}
BIO_free(bio_out);
}
Expand Down Expand Up @@ -3513,7 +3520,7 @@ PHP_FUNCTION(openssl_cms_read)
ZVAL_STRINGL(&zcert, bio_buf->data, bio_buf->length);
add_index_zval(zout, i, &zcert);
}
BIO_reset(bio_out);
(void)BIO_reset(bio_out);
}
BIO_free(bio_out);
}
Expand All @@ -3533,7 +3540,7 @@ PHP_FUNCTION(openssl_cms_read)
ZVAL_STRINGL(&zcert, bio_buf->data, bio_buf->length);
add_index_zval(zout, i, &zcert);
}
BIO_reset(bio_out);
(void)BIO_reset(bio_out);
}
BIO_free(bio_out);
}
Expand Down
8 changes: 5 additions & 3 deletions ext/openssl/openssl_backend_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1088,13 +1088,15 @@ zend_result php_openssl_csr_make(struct php_x509_request * req, X509_REQ * csr,
}
}
}

if (!X509_REQ_set_pubkey(csr, req->priv_key)) {
php_openssl_store_errors();
}
} else {
php_openssl_store_errors();
return FAILURE;
}

if (!X509_REQ_set_pubkey(csr, req->priv_key)) {
php_openssl_store_errors();
}
return SUCCESS;
}

Expand Down
23 changes: 21 additions & 2 deletions ext/openssl/openssl_backend_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,14 @@ static bool php_openssl_pkey_init_dsa_data(DSA *dsa, zval *data, bool *is_privat
OPENSSL_PKEY_SET_BN(data, p);
OPENSSL_PKEY_SET_BN(data, q);
OPENSSL_PKEY_SET_BN(data, g);
if (!p || !q || !g || !DSA_set0_pqg(dsa, p, q, g)) {
if (!p || !q || !g) {
BN_free(p);
BN_free(q);
BN_free(g);
return false;
}

if (!DSA_set0_pqg(dsa, p, q, g)) {
return false;
}

Expand Down Expand Up @@ -201,7 +208,12 @@ static bool php_openssl_pkey_init_dh_data(DH *dh, zval *data, bool *is_private)
OPENSSL_PKEY_SET_BN(data, p);
OPENSSL_PKEY_SET_BN(data, q);
OPENSSL_PKEY_SET_BN(data, g);
if (!p || !g || !DH_set0_pqg(dh, p, q, g)) {
if (!p || !q) {
BN_free(p);
return false;
}

if (!DH_set0_pqg(dh, p, q, g)) {
return false;
}

Expand All @@ -214,6 +226,10 @@ static bool php_openssl_pkey_init_dh_data(DH *dh, zval *data, bool *is_private)
if (priv_key) {
pub_key = php_openssl_dh_pub_from_priv(priv_key, g, p);
if (pub_key == NULL) {
BN_free(p);
BN_free(q);
BN_free(g);
BN_free(priv_key);
return false;
}
return DH_set0_key(dh, pub_key, priv_key);
Expand Down Expand Up @@ -261,6 +277,9 @@ static bool php_openssl_pkey_init_ec_data(EC_KEY *eckey, zval *data, bool *is_pr
EC_POINT *point_q = NULL;
EC_GROUP *group = NULL;
BN_CTX *bctx = BN_CTX_new();
if (!bctx) {
goto clean_exit;
}

*is_private = false;

Expand Down
5 changes: 2 additions & 3 deletions ext/openssl/tests/gh21031.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ $clientCode = <<<'CODE'
],
]);
var_dump(file_get_contents("https://cs.php.net/", false, $clientCtx));
var_dump(@file_get_contents("https://cs.php.net/", false, $clientCtx));
phpt_notify('proxy');
phpt_notify('server');
Expand All @@ -77,6 +77,5 @@ ServerClientTestCase::getInstance()->run($clientCode, [
'proxy' => $proxyCode,
]);
?>
--EXPECTF--
Warning: file_get_contents(https://cs.php.net/): Failed to open stream: Cannot connect to HTTPS server through proxy in %s
--EXPECT--
bool(false)
7 changes: 3 additions & 4 deletions ext/openssl/xp_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ static bool php_openssl_x509_fingerprint_match(X509 *peer, zval *val)

static bool php_openssl_matches_wildcard_name(const char *subjectname, const char *certname) /* {{{ */
{
char *wildcard = NULL;
const char *wildcard = NULL;
ptrdiff_t prefix_len;
size_t suffix_len, subject_len;

Expand Down Expand Up @@ -1691,7 +1691,8 @@ static zend_result php_openssl_setup_crypto(php_stream *stream,

sslsock->ssl_handle = SSL_new(sslsock->ctx);

if (sslsock->ssl_handle == NULL) {
if (sslsock->ssl_handle == NULL
|| !SSL_set_ex_data(sslsock->ssl_handle, php_openssl_get_ssl_stream_data_index(), stream)) {
php_error_docref(NULL, E_WARNING, "SSL handle creation failure");
SSL_CTX_free(sslsock->ctx);
sslsock->ctx = NULL;
Expand All @@ -1702,8 +1703,6 @@ static zend_result php_openssl_setup_crypto(php_stream *stream,
}
#endif
return FAILURE;
} else {
SSL_set_ex_data(sslsock->ssl_handle, php_openssl_get_ssl_stream_data_index(), stream);
}

if (!SSL_set_fd(sslsock->ssl_handle, sslsock->s.socket)) {
Expand Down