Skip to content

Commit db579e2

Browse files
committed
Nit fixing
1 parent 00fe73e commit db579e2

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/core/tsi/ssl_transport_security.cc

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ struct tsi_ssl_handshaker : public tsi_handshaker,
190190
// or nullopt if not.
191191
std::optional<HandshakerNextArgs> handshaker_next_args ABSL_GUARDED_BY(mu);
192192
void MaybeSetError(std::string error) const
193-
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&tsi_ssl_handshaker::mu) {
193+
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&mu) {
194194
if (!handshaker_next_args.has_value()) return;
195195
if (handshaker_next_args->error_ptr == nullptr) return;
196196
*handshaker_next_args->error_ptr = std::move(error);
@@ -2032,9 +2032,9 @@ static tsi_result ssl_handshaker_result_create(tsi_ssl_handshaker* handshaker,
20322032
unsigned char* unused_bytes,
20332033
size_t unused_bytes_size)
20342034
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&tsi_ssl_handshaker::mu) {
2035-
if (handshaker == nullptr ||
2036-
(unused_bytes_size > 0 && unused_bytes == nullptr)) {
2037-
if (handshaker != nullptr) handshaker->MaybeSetError("invalid argument");
2035+
if (handshaker == nullptr) return TSI_INVALID_ARGUMENT;
2036+
if (unused_bytes_size > 0 && unused_bytes == nullptr) {
2037+
handshaker->MaybeSetError("invalid argument");
20382038
return TSI_INVALID_ARGUMENT;
20392039
}
20402040
tsi_ssl_handshaker_result* result =
@@ -2125,9 +2125,14 @@ static tsi_result ssl_handshaker_do_handshake(tsi_ssl_handshaker* impl)
21252125
LOG(INFO) << "Handshake failed with error "
21262126
<< tsi::SslErrorString(ssl_result) << ": " << err_str
21272127
<< verify_result_str;
2128-
impl->MaybeSetError(absl::StrCat(
2129-
tsi::SslErrorString(ssl_result), ": ", err_str, verify_result_str,
2130-
": ", impl->signed_bytes.status().ToString()));
2128+
std::string signer_error = "";
2129+
#if defined(OPENSSL_IS_BORINGSSL)
2130+
signer_error =
2131+
absl::StrCat(": ", impl->signed_bytes.status().ToString());
2132+
#endif
2133+
impl->MaybeSetError(absl::StrCat(tsi::SslErrorString(ssl_result), ": ",
2134+
err_str, verify_result_str,
2135+
signer_error));
21312136
impl->result = TSI_PROTOCOL_FAILURE;
21322137
return impl->result;
21332138
}
@@ -2167,9 +2172,9 @@ static tsi_result ssl_bytes_remaining(tsi_ssl_handshaker* impl,
21672172
unsigned char** bytes_remaining,
21682173
size_t* bytes_remaining_size)
21692174
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&tsi_ssl_handshaker::mu) {
2170-
if (impl == nullptr || bytes_remaining == nullptr ||
2171-
bytes_remaining_size == nullptr) {
2172-
if (impl != nullptr) impl->MaybeSetError("invalid argument");
2175+
if (impl == nullptr) return TSI_INVALID_ARGUMENT;
2176+
if (bytes_remaining == nullptr || bytes_remaining_size == nullptr) {
2177+
impl->MaybeSetError("invalid argument");
21732178
return TSI_INVALID_ARGUMENT;
21742179
}
21752180
// Attempt to read all of the bytes in SSL's read BIO. These bytes should

0 commit comments

Comments
 (0)