Skip to content

Fix 2 OpenSSL error handling bugs #10705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
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
9 changes: 6 additions & 3 deletions ext/openssl/xp_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ static int php_openssl_set_server_dh_param(php_stream * stream, SSL_CTX *ctx) /*
return FAILURE;
}

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

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

php_openssl_set_server_dh_param(stream, ctx);
if (php_openssl_set_server_dh_param(stream, ctx) == FAILURE) {
return FAILURE;
}

zv = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "ssl", "single_dh_use");
if (zv == NULL || zend_is_true(zv)) {
ssl_ctx_options |= SSL_OP_SINGLE_DH_USE;
Expand Down