Skip to content

Commit b09be29

Browse files
nielsdosdevnexen
authored andcommitted
Fix incorrect error checking in php_openssl_set_server_dh_param()
SSL_CTX_set_tmp_dh() and SSL_CTX_set0_tmp_dh_pkey() return 1 on success and 0 on error. But only < 0 was checked which means that errors were never caught. Closes GH-10705.
1 parent eb7bb34 commit b09be29

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ PHP NEWS
5454
- Opcache:
5555
. Fix incorrect page_size check. (nielsdos)
5656

57+
- OpenSSL:
58+
. Fixed php_openssl_set_server_dh_param() DH params errors handling. (nielsdos)
59+
5760
- PDO OCI:
5861
. Fixed bug #60994 (Reading a multibyte CLOB caps at 8192 chars).
5962
(Michael Voříšek)

ext/openssl/xp_ssl.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ static int php_openssl_set_server_dh_param(php_stream * stream, SSL_CTX *ctx) /*
12221222
return FAILURE;
12231223
}
12241224

1225-
if (SSL_CTX_set0_tmp_dh_pkey(ctx, pkey) < 0) {
1225+
if (SSL_CTX_set0_tmp_dh_pkey(ctx, pkey) == 0) {
12261226
php_error_docref(NULL, E_WARNING, "Failed assigning DH params");
12271227
EVP_PKEY_free(pkey);
12281228
return FAILURE;
@@ -1236,7 +1236,7 @@ static int php_openssl_set_server_dh_param(php_stream * stream, SSL_CTX *ctx) /*
12361236
return FAILURE;
12371237
}
12381238

1239-
if (SSL_CTX_set_tmp_dh(ctx, dh) < 0) {
1239+
if (SSL_CTX_set_tmp_dh(ctx, dh) == 0) {
12401240
php_error_docref(NULL, E_WARNING, "Failed assigning DH params");
12411241
DH_free(dh);
12421242
return FAILURE;
@@ -1305,7 +1305,10 @@ static int php_openssl_set_server_specific_opts(php_stream *stream, SSL_CTX *ctx
13051305
php_error_docref(NULL, E_WARNING, "rsa_key_size context option has been removed");
13061306
}
13071307

1308-
php_openssl_set_server_dh_param(stream, ctx);
1308+
if (php_openssl_set_server_dh_param(stream, ctx) == FAILURE) {
1309+
return FAILURE;
1310+
}
1311+
13091312
zv = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "ssl", "single_dh_use");
13101313
if (zv == NULL || zend_is_true(zv)) {
13111314
ssl_ctx_options |= SSL_OP_SINGLE_DH_USE;

0 commit comments

Comments
 (0)