Skip to content
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

Coverity fixes for P173127397 #2014

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
19 changes: 16 additions & 3 deletions tool/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

#if !defined(OPENSSL_WINDOWS)
#include <sys/select.h>
#include <unistd.h>
static int closesocket(int sock) {
return close(sock);
}
#else
OPENSSL_MSVC_PRAGMA(warning(push, 3))
#include <winsock2.h>
Expand Down Expand Up @@ -318,8 +322,11 @@ static bool DoConnection(SSL_CTX *ctx,
bool (*cb)(SSL *ssl, int sock), bool is_openssl_s_client) {
int sock = -1;
if (args_map.count("-http-tunnel") != 0) {
if (!Connect(&sock, args_map["-http-tunnel"], is_openssl_s_client) ||
!DoHTTPTunnel(sock, args_map["-connect"])) {
if (!Connect(&sock, args_map["-http-tunnel"], is_openssl_s_client)) {
return false;
}
if (!DoHTTPTunnel(sock, args_map["-connect"])) {
closesocket(sock);
return false;
}
} else if (!Connect(&sock, args_map["-connect"], is_openssl_s_client)) {
Expand All @@ -335,19 +342,25 @@ static bool DoConnection(SSL_CTX *ctx,
const std::string& starttls = args_map["-starttls"];
if (starttls == "smtp") {
if (!DoSMTPStartTLS(sock)) {
closesocket(sock);
return false;
}
} else {
closesocket(sock);
fprintf(stderr, "Unknown value for -starttls: %s\n", starttls.c_str());
return false;
}
}

// BIO takes ownership of |sock| from this point forward.
bssl::UniquePtr<BIO> bio(BIO_new_socket(sock, BIO_CLOSE));
bssl::UniquePtr<SSL> ssl(SSL_new(ctx));

if (args_map.count("-server-name") != 0) {
SSL_set_tlsext_host_name(ssl.get(), args_map["-server-name"].c_str());
if (!SSL_set_tlsext_host_name(ssl.get(),
args_map["-server-name"].c_str())) {
return false;
}
}

if (args_map.count("-ech-grease") != 0) {
Expand Down
1 change: 1 addition & 0 deletions tool/transport_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ bool Connect(int *out_sock, const std::string &hostname_and_port, bool quiet) {

if (connect(*out_sock, result->ai_addr, result->ai_addrlen) != 0) {
PrintSocketError("connect");
closesocket(*out_sock);
goto out;
}
ok = true;
Expand Down
Loading