diff options
Diffstat (limited to 'src/core/tsi')
-rw-r--r-- | src/core/tsi/fake_transport_security.cc | 51 | ||||
-rw-r--r-- | src/core/tsi/ssl_transport_security.cc | 82 | ||||
-rw-r--r-- | src/core/tsi/transport_security.cc | 4 | ||||
-rw-r--r-- | src/core/tsi/transport_security_adapter.cc | 22 |
4 files changed, 99 insertions, 60 deletions
diff --git a/src/core/tsi/fake_transport_security.cc b/src/core/tsi/fake_transport_security.cc index c7eb750a5b..b5b7203d20 100644 --- a/src/core/tsi/fake_transport_security.cc +++ b/src/core/tsi/fake_transport_security.cc @@ -112,7 +112,8 @@ static tsi_result tsi_fake_handshake_message_from_string( static uint32_t load32_little_endian(const unsigned char* buf) { return (static_cast<uint32_t>(buf[0]) | static_cast<uint32_t>(buf[1] << 8) | - static_cast<uint32_t>(buf[2] << 16) | static_cast<uint32_t>(buf[3] << 24)); + static_cast<uint32_t>(buf[2] << 16) | + static_cast<uint32_t>(buf[3] << 24)); } static void store32_little_endian(uint32_t value, unsigned char* buf) { @@ -155,7 +156,8 @@ static void tsi_fake_frame_reset(tsi_fake_frame* frame, int needs_draining) { static void tsi_fake_frame_ensure_size(tsi_fake_frame* frame) { if (frame->data == nullptr) { frame->allocated_size = frame->size; - frame->data = static_cast<unsigned char*>(gpr_malloc(frame->allocated_size)); + frame->data = + static_cast<unsigned char*>(gpr_malloc(frame->allocated_size)); } else if (frame->size > frame->allocated_size) { unsigned char* new_data = static_cast<unsigned char*>(gpr_realloc(frame->data, frame->size)); @@ -177,7 +179,8 @@ static tsi_result tsi_fake_frame_decode(const unsigned char* incoming_bytes, if (frame->needs_draining) return TSI_INTERNAL_ERROR; if (frame->data == nullptr) { frame->allocated_size = TSI_FAKE_FRAME_INITIAL_ALLOCATED_SIZE; - frame->data = static_cast<unsigned char*>(gpr_malloc(frame->allocated_size)); + frame->data = + static_cast<unsigned char*>(gpr_malloc(frame->allocated_size)); } if (frame->offset < TSI_FAKE_FRAME_HEADER_SIZE) { @@ -258,7 +261,8 @@ static tsi_result fake_protector_protect(tsi_frame_protector* self, unsigned char* protected_output_frames, size_t* protected_output_frames_size) { tsi_result result = TSI_OK; - tsi_fake_frame_protector* impl = reinterpret_cast<tsi_fake_frame_protector*>(self); + tsi_fake_frame_protector* impl = + reinterpret_cast<tsi_fake_frame_protector*>(self); unsigned char frame_header[TSI_FAKE_FRAME_HEADER_SIZE]; tsi_fake_frame* frame = &impl->protect_frame; size_t saved_output_size = *protected_output_frames_size; @@ -287,7 +291,8 @@ static tsi_result fake_protector_protect(tsi_frame_protector* self, if (frame->size == 0) { /* New frame, create a header. */ size_t written_in_frame_size = 0; - store32_little_endian(static_cast<uint32_t>(impl->max_frame_size), frame_header); + store32_little_endian(static_cast<uint32_t>(impl->max_frame_size), + frame_header); written_in_frame_size = TSI_FAKE_FRAME_HEADER_SIZE; result = tsi_fake_frame_decode(frame_header, &written_in_frame_size, frame); if (result != TSI_INCOMPLETE_DATA) { @@ -317,7 +322,8 @@ static tsi_result fake_protector_protect_flush( tsi_frame_protector* self, unsigned char* protected_output_frames, size_t* protected_output_frames_size, size_t* still_pending_size) { tsi_result result = TSI_OK; - tsi_fake_frame_protector* impl = reinterpret_cast<tsi_fake_frame_protector*>(self); + tsi_fake_frame_protector* impl = + reinterpret_cast<tsi_fake_frame_protector*>(self); tsi_fake_frame* frame = &impl->protect_frame; if (!frame->needs_draining) { /* Create a short frame. */ @@ -339,7 +345,8 @@ static tsi_result fake_protector_unprotect( size_t* protected_frames_bytes_size, unsigned char* unprotected_bytes, size_t* unprotected_bytes_size) { tsi_result result = TSI_OK; - tsi_fake_frame_protector* impl = reinterpret_cast<tsi_fake_frame_protector*>(self); + tsi_fake_frame_protector* impl = + reinterpret_cast<tsi_fake_frame_protector*>(self); tsi_fake_frame* frame = &impl->unprotect_frame; size_t saved_output_size = *unprotected_bytes_size; size_t drained_size = 0; @@ -384,7 +391,8 @@ static tsi_result fake_protector_unprotect( } static void fake_protector_destroy(tsi_frame_protector* self) { - tsi_fake_frame_protector* impl = reinterpret_cast<tsi_fake_frame_protector*>(self); + tsi_fake_frame_protector* impl = + reinterpret_cast<tsi_fake_frame_protector*>(self); tsi_fake_frame_destruct(&impl->protect_frame); tsi_fake_frame_destruct(&impl->unprotect_frame); gpr_free(self); @@ -414,7 +422,8 @@ static tsi_result fake_zero_copy_grpc_protector_protect( GPR_MIN(impl->max_frame_size, unprotected_slices->length + TSI_FAKE_FRAME_HEADER_SIZE); grpc_slice slice = GRPC_SLICE_MALLOC(TSI_FAKE_FRAME_HEADER_SIZE); - store32_little_endian(static_cast<uint32_t>(frame_length), GRPC_SLICE_START_PTR(slice)); + store32_little_endian(static_cast<uint32_t>(frame_length), + GRPC_SLICE_START_PTR(slice)); grpc_slice_buffer_add(protected_slices, slice); size_t data_length = frame_length - TSI_FAKE_FRAME_HEADER_SIZE; grpc_slice_buffer_move_first(unprotected_slices, data_length, @@ -520,7 +529,8 @@ static tsi_result fake_handshaker_result_get_unused_bytes( } static void fake_handshaker_result_destroy(tsi_handshaker_result* self) { - fake_handshaker_result* result = reinterpret_cast<fake_handshaker_result*>(self); + fake_handshaker_result* result = + reinterpret_cast<fake_handshaker_result*>(self); gpr_free(result->unused_bytes); gpr_free(self); } @@ -544,7 +554,8 @@ static tsi_result fake_handshaker_result_create( static_cast<fake_handshaker_result*>(gpr_zalloc(sizeof(*result))); result->base.vtable = &handshaker_result_vtable; if (unused_bytes_size > 0) { - result->unused_bytes = static_cast<unsigned char*>(gpr_malloc(unused_bytes_size)); + result->unused_bytes = + static_cast<unsigned char*>(gpr_malloc(unused_bytes_size)); memcpy(result->unused_bytes, unused_bytes, unused_bytes_size); } result->unused_bytes_size = unused_bytes_size; @@ -612,7 +623,8 @@ static tsi_result fake_handshaker_process_bytes_from_peer( /* We now have a complete frame. */ result = tsi_fake_handshake_message_from_string( - reinterpret_cast<const char*>(impl->incoming_frame.data) + TSI_FAKE_FRAME_HEADER_SIZE, + reinterpret_cast<const char*>(impl->incoming_frame.data) + + TSI_FAKE_FRAME_HEADER_SIZE, &received_msg); if (result != TSI_OK) { impl->result = result; @@ -663,7 +675,8 @@ static tsi_result fake_handshaker_next( handshaker_result == nullptr) { return TSI_INVALID_ARGUMENT; } - tsi_fake_handshaker* handshaker = reinterpret_cast<tsi_fake_handshaker*>(self); + tsi_fake_handshaker* handshaker = + reinterpret_cast<tsi_fake_handshaker*>(self); tsi_result result = TSI_OK; /* Decode and process a handshake frame from the peer. */ @@ -684,9 +697,9 @@ static tsi_result fake_handshaker_next( offset += sent_bytes_size; if (result == TSI_INCOMPLETE_DATA) { handshaker->outgoing_bytes_buffer_size *= 2; - handshaker->outgoing_bytes_buffer = - static_cast<unsigned char*>(gpr_realloc(handshaker->outgoing_bytes_buffer, - handshaker->outgoing_bytes_buffer_size)); + handshaker->outgoing_bytes_buffer = static_cast<unsigned char*>( + gpr_realloc(handshaker->outgoing_bytes_buffer, + handshaker->outgoing_bytes_buffer_size)); } } while (result == TSI_INCOMPLETE_DATA); if (result != TSI_OK) return result; @@ -727,7 +740,8 @@ static const tsi_handshaker_vtable handshaker_vtable = { }; tsi_handshaker* tsi_create_fake_handshaker(int is_client) { - tsi_fake_handshaker* impl = static_cast<tsi_fake_handshaker*>(gpr_zalloc(sizeof(*impl))); + tsi_fake_handshaker* impl = + static_cast<tsi_fake_handshaker*>(gpr_zalloc(sizeof(*impl))); impl->base.vtable = &handshaker_vtable; impl->is_client = is_client; impl->result = TSI_HANDSHAKE_IN_PROGRESS; @@ -759,7 +773,8 @@ tsi_frame_protector* tsi_create_fake_frame_protector( tsi_zero_copy_grpc_protector* tsi_create_fake_zero_copy_grpc_protector( size_t* max_protected_frame_size) { tsi_fake_zero_copy_grpc_protector* impl = - static_cast<tsi_fake_zero_copy_grpc_protector*>(gpr_zalloc(sizeof(*impl))); + static_cast<tsi_fake_zero_copy_grpc_protector*>( + gpr_zalloc(sizeof(*impl))); grpc_slice_buffer_init(&impl->header_sb); grpc_slice_buffer_init(&impl->protected_sb); impl->max_frame_size = (max_protected_frame_size == nullptr) diff --git a/src/core/tsi/ssl_transport_security.cc b/src/core/tsi/ssl_transport_security.cc index b32649a8b9..643b5a5c79 100644 --- a/src/core/tsi/ssl_transport_security.cc +++ b/src/core/tsi/ssl_transport_security.cc @@ -137,7 +137,8 @@ static void init_openssl(void) { OpenSSL_add_all_algorithms(); num_locks = CRYPTO_num_locks(); GPR_ASSERT(num_locks > 0); - openssl_mutexes = static_cast<gpr_mu*>(gpr_malloc(static_cast<size_t>(num_locks) * sizeof(gpr_mu))); + openssl_mutexes = static_cast<gpr_mu*>( + gpr_malloc(static_cast<size_t>(num_locks) * sizeof(gpr_mu))); for (i = 0; i < CRYPTO_num_locks(); i++) { gpr_mu_init(&openssl_mutexes[i]); } @@ -275,8 +276,8 @@ static tsi_result peer_property_from_x509_common_name( } result = tsi_construct_string_peer_property( TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, - common_name == nullptr ? "" : reinterpret_cast<const char*>(common_name), common_name_size, - property); + common_name == nullptr ? "" : reinterpret_cast<const char*>(common_name), + common_name_size, property); OPENSSL_free(common_name); return result; } @@ -295,7 +296,8 @@ static tsi_result add_pem_certificate(X509* cert, tsi_peer_property* property) { return TSI_INTERNAL_ERROR; } tsi_result result = tsi_construct_string_peer_property( - TSI_X509_PEM_CERT_PROPERTY, (const char*)contents, static_cast<size_t>(len), property); + TSI_X509_PEM_CERT_PROPERTY, (const char*)contents, + static_cast<size_t>(len), property); BIO_free(bio); return result; } @@ -324,8 +326,9 @@ static tsi_result add_subject_alt_names_properties_to_peer( break; } result = tsi_construct_string_peer_property( - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, reinterpret_cast<const char*>(name), - static_cast<size_t>(name_size), &peer->properties[peer->property_count++]); + TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, + reinterpret_cast<const char*>(name), static_cast<size_t>(name_size), + &peer->properties[peer->property_count++]); OPENSSL_free(name); } else if (subject_alt_name->type == GEN_IPADD) { char ntop_buf[INET6_ADDRSTRLEN]; @@ -361,11 +364,12 @@ static tsi_result add_subject_alt_names_properties_to_peer( static tsi_result peer_from_x509(X509* cert, int include_certificate_type, tsi_peer* peer) { /* TODO(jboeuf): Maybe add more properties. */ - GENERAL_NAMES* subject_alt_names = static_cast<GENERAL_NAMES*>(X509_get_ext_d2i( - cert, NID_subject_alt_name, nullptr, nullptr)); - int subject_alt_name_count = (subject_alt_names != nullptr) - ? static_cast<int>(sk_GENERAL_NAME_num(subject_alt_names)) - : 0; + GENERAL_NAMES* subject_alt_names = static_cast<GENERAL_NAMES*>( + X509_get_ext_d2i(cert, NID_subject_alt_name, nullptr, nullptr)); + int subject_alt_name_count = + (subject_alt_names != nullptr) + ? static_cast<int>(sk_GENERAL_NAME_num(subject_alt_names)) + : 0; size_t property_count; tsi_result result; GPR_ASSERT(subject_alt_name_count >= 0); @@ -418,8 +422,8 @@ static tsi_result do_ssl_read(SSL* ssl, unsigned char* unprotected_bytes, size_t* unprotected_bytes_size) { int read_from_ssl; GPR_ASSERT(*unprotected_bytes_size <= INT_MAX); - read_from_ssl = - SSL_read(ssl, unprotected_bytes, static_cast<int>(*unprotected_bytes_size)); + read_from_ssl = SSL_read(ssl, unprotected_bytes, + static_cast<int>(*unprotected_bytes_size)); if (read_from_ssl <= 0) { read_from_ssl = SSL_get_error(ssl, read_from_ssl); switch (read_from_ssl) { @@ -451,8 +455,8 @@ static tsi_result do_ssl_write(SSL* ssl, unsigned char* unprotected_bytes, size_t unprotected_bytes_size) { int ssl_write_result; GPR_ASSERT(unprotected_bytes_size <= INT_MAX); - ssl_write_result = - SSL_write(ssl, unprotected_bytes, static_cast<int>(unprotected_bytes_size)); + ssl_write_result = SSL_write(ssl, unprotected_bytes, + static_cast<int>(unprotected_bytes_size)); if (ssl_write_result < 0) { ssl_write_result = SSL_get_error(ssl, ssl_write_result); if (ssl_write_result == SSL_ERROR_WANT_READ) { @@ -476,7 +480,8 @@ static tsi_result ssl_ctx_use_certificate_chain(SSL_CTX* context, X509* certificate = nullptr; BIO* pem; GPR_ASSERT(pem_cert_chain_size <= INT_MAX); - pem = BIO_new_mem_buf((void*)pem_cert_chain, static_cast<int>(pem_cert_chain_size)); + pem = BIO_new_mem_buf((void*)pem_cert_chain, + static_cast<int>(pem_cert_chain_size)); if (pem == nullptr) return TSI_OUT_OF_RESOURCES; do { @@ -683,12 +688,14 @@ static tsi_result build_alpn_protocol_name_list( size_t length = alpn_protocols[i] == nullptr ? 0 : strlen(alpn_protocols[i]); if (length == 0 || length > 255) { - gpr_log(GPR_ERROR, "Invalid protocol name length: %d.", static_cast<int>(length)); + gpr_log(GPR_ERROR, "Invalid protocol name length: %d.", + static_cast<int>(length)); return TSI_INVALID_ARGUMENT; } *protocol_name_list_length += length + 1; } - *protocol_name_list = static_cast<unsigned char*>(gpr_malloc(*protocol_name_list_length)); + *protocol_name_list = + static_cast<unsigned char*>(gpr_malloc(*protocol_name_list_length)); if (*protocol_name_list == nullptr) return TSI_OUT_OF_RESOURCES; current = *protocol_name_list; for (i = 0; i < num_alpn_protocols; i++) { @@ -721,7 +728,8 @@ static tsi_result ssl_protector_protect(tsi_frame_protector* self, size_t* unprotected_bytes_size, unsigned char* protected_output_frames, size_t* protected_output_frames_size) { - tsi_ssl_frame_protector* impl = reinterpret_cast<tsi_ssl_frame_protector*>(self); + tsi_ssl_frame_protector* impl = + reinterpret_cast<tsi_ssl_frame_protector*>(self); int read_from_ssl; size_t available; tsi_result result = TSI_OK; @@ -775,7 +783,8 @@ static tsi_result ssl_protector_protect_flush( tsi_frame_protector* self, unsigned char* protected_output_frames, size_t* protected_output_frames_size, size_t* still_pending_size) { tsi_result result = TSI_OK; - tsi_ssl_frame_protector* impl = reinterpret_cast<tsi_ssl_frame_protector*>(self); + tsi_ssl_frame_protector* impl = + reinterpret_cast<tsi_ssl_frame_protector*>(self); int read_from_ssl = 0; int pending; @@ -812,7 +821,8 @@ static tsi_result ssl_protector_unprotect( int written_into_ssl = 0; size_t output_bytes_size = *unprotected_bytes_size; size_t output_bytes_offset = 0; - tsi_ssl_frame_protector* impl = reinterpret_cast<tsi_ssl_frame_protector*>(self); + tsi_ssl_frame_protector* impl = + reinterpret_cast<tsi_ssl_frame_protector*>(self); /* First, try to read remaining data from ssl. */ result = do_ssl_read(impl->ssl, unprotected_bytes, unprotected_bytes_size); @@ -847,7 +857,8 @@ static tsi_result ssl_protector_unprotect( } static void ssl_protector_destroy(tsi_frame_protector* self) { - tsi_ssl_frame_protector* impl = reinterpret_cast<tsi_ssl_frame_protector*>(self); + tsi_ssl_frame_protector* impl = + reinterpret_cast<tsi_ssl_frame_protector*>(self); if (impl->buffer != nullptr) gpr_free(impl->buffer); if (impl->ssl != nullptr) SSL_free(impl->ssl); if (impl->network_io != nullptr) BIO_free(impl->network_io); @@ -914,7 +925,8 @@ static tsi_result ssl_handshaker_get_bytes_to_send_to_peer(tsi_handshaker* self, return TSI_INVALID_ARGUMENT; } GPR_ASSERT(*bytes_size <= INT_MAX); - bytes_read_from_ssl = BIO_read(impl->network_io, bytes, static_cast<int>(*bytes_size)); + bytes_read_from_ssl = + BIO_read(impl->network_io, bytes, static_cast<int>(*bytes_size)); if (bytes_read_from_ssl < 0) { *bytes_size = 0; if (!BIO_should_retry(impl->network_io)) { @@ -1005,14 +1017,15 @@ static tsi_result ssl_handshaker_extract_peer(tsi_handshaker* self, } if (alpn_selected != nullptr) { size_t i; - tsi_peer_property* new_properties = static_cast<tsi_peer_property*>(gpr_zalloc( - sizeof(*new_properties) * (peer->property_count + 1))); + tsi_peer_property* new_properties = static_cast<tsi_peer_property*>( + gpr_zalloc(sizeof(*new_properties) * (peer->property_count + 1))); for (i = 0; i < peer->property_count; i++) { new_properties[i] = peer->properties[i]; } result = tsi_construct_string_peer_property( - TSI_SSL_ALPN_SELECTED_PROTOCOL, reinterpret_cast<const char*>(alpn_selected), - alpn_selected_len, &new_properties[peer->property_count]); + TSI_SSL_ALPN_SELECTED_PROTOCOL, + reinterpret_cast<const char*>(alpn_selected), alpn_selected_len, + &new_properties[peer->property_count]); if (result != TSI_OK) { gpr_free(new_properties); return result; @@ -1031,7 +1044,8 @@ static tsi_result ssl_handshaker_create_frame_protector( TSI_SSL_MAX_PROTECTED_FRAME_SIZE_UPPER_BOUND; tsi_ssl_handshaker* impl = reinterpret_cast<tsi_ssl_handshaker*>(self); tsi_ssl_frame_protector* protector_impl = - static_cast<tsi_ssl_frame_protector*>(gpr_zalloc(sizeof(*protector_impl))); + static_cast<tsi_ssl_frame_protector*>( + gpr_zalloc(sizeof(*protector_impl))); if (max_output_protected_frame_size != nullptr) { if (*max_output_protected_frame_size > @@ -1157,11 +1171,13 @@ static int select_protocol_list(const unsigned char** out, const unsigned char* server_list, size_t server_list_len) { const unsigned char* client_current = client_list; - while (static_cast<unsigned int>(client_current - client_list) < client_list_len) { + while (static_cast<unsigned int>(client_current - client_list) < + client_list_len) { unsigned char client_current_len = *(client_current++); const unsigned char* server_current = server_list; while ((server_current >= server_list) && - static_cast<uintptr_t>(server_current - server_list) < server_list_len) { + static_cast<uintptr_t>(server_current - server_list) < + server_list_len) { unsigned char server_current_len = *(server_current++); if ((client_current_len == server_current_len) && !memcmp(client_current, server_current, server_current_len)) { @@ -1367,7 +1383,8 @@ tsi_result tsi_create_ssl_client_handshaker_factory( return TSI_INVALID_ARGUMENT; } - impl = static_cast<tsi_ssl_client_handshaker_factory*>(gpr_zalloc(sizeof(*impl))); + impl = static_cast<tsi_ssl_client_handshaker_factory*>( + gpr_zalloc(sizeof(*impl))); tsi_ssl_handshaker_factory_init(&impl->base); impl->base.vtable = &client_handshaker_factory_vtable; @@ -1452,7 +1469,8 @@ tsi_result tsi_create_ssl_server_handshaker_factory_ex( return TSI_INVALID_ARGUMENT; } - impl = static_cast<tsi_ssl_server_handshaker_factory*>(gpr_zalloc(sizeof(*impl))); + impl = static_cast<tsi_ssl_server_handshaker_factory*>( + gpr_zalloc(sizeof(*impl))); tsi_ssl_handshaker_factory_init(&impl->base); impl->base.vtable = &server_handshaker_factory_vtable; diff --git a/src/core/tsi/transport_security.cc b/src/core/tsi/transport_security.cc index 5cfdf6fc32..0c8e3e9dcc 100644 --- a/src/core/tsi/transport_security.cc +++ b/src/core/tsi/transport_security.cc @@ -316,8 +316,8 @@ tsi_result tsi_construct_string_peer_property(const char* name, tsi_result tsi_construct_peer(size_t property_count, tsi_peer* peer) { memset(peer, 0, sizeof(tsi_peer)); if (property_count > 0) { - peer->properties = static_cast<tsi_peer_property*>(gpr_zalloc( - property_count * sizeof(tsi_peer_property))); + peer->properties = static_cast<tsi_peer_property*>( + gpr_zalloc(property_count * sizeof(tsi_peer_property))); peer->property_count = property_count; } return TSI_OK; diff --git a/src/core/tsi/transport_security_adapter.cc b/src/core/tsi/transport_security_adapter.cc index e57a42ad6c..5f094b3201 100644 --- a/src/core/tsi/transport_security_adapter.cc +++ b/src/core/tsi/transport_security_adapter.cc @@ -59,7 +59,8 @@ static tsi_result adapter_result_get_unused_bytes( } static void adapter_result_destroy(tsi_handshaker_result* self) { - tsi_adapter_handshaker_result* impl = reinterpret_cast<tsi_adapter_handshaker_result*>(self); + tsi_adapter_handshaker_result* impl = + reinterpret_cast<tsi_adapter_handshaker_result*>(self); tsi_handshaker_destroy(impl->wrapped); gpr_free(impl->unused_bytes); gpr_free(self); @@ -87,7 +88,8 @@ static tsi_result tsi_adapter_create_handshaker_result( impl->wrapped = wrapped; impl->unused_bytes_size = unused_bytes_size; if (unused_bytes_size > 0) { - impl->unused_bytes = static_cast<unsigned char*>(gpr_malloc(unused_bytes_size)); + impl->unused_bytes = + static_cast<unsigned char*>(gpr_malloc(unused_bytes_size)); memcpy(impl->unused_bytes, unused_bytes, unused_bytes_size); } else { impl->unused_bytes = nullptr; @@ -137,7 +139,8 @@ static tsi_result adapter_create_frame_protector( } static void adapter_destroy(tsi_handshaker* self) { - tsi_adapter_handshaker* impl = reinterpret_cast<tsi_adapter_handshaker*>(self); + tsi_adapter_handshaker* impl = + reinterpret_cast<tsi_adapter_handshaker*>(self); tsi_handshaker_destroy(impl->wrapped); gpr_free(impl->adapter_buffer); gpr_free(self); @@ -156,7 +159,8 @@ static tsi_result adapter_next( } /* If there are received bytes, process them first. */ - tsi_adapter_handshaker* impl = reinterpret_cast<tsi_adapter_handshaker*>(self); + tsi_adapter_handshaker* impl = + reinterpret_cast<tsi_adapter_handshaker*>(self); tsi_result status = TSI_OK; size_t bytes_consumed = received_bytes_size; if (received_bytes_size > 0) { @@ -174,8 +178,8 @@ static tsi_result adapter_next( offset += to_send_size; if (status == TSI_INCOMPLETE_DATA) { impl->adapter_buffer_size *= 2; - impl->adapter_buffer = static_cast<unsigned char*>(gpr_realloc( - impl->adapter_buffer, impl->adapter_buffer_size)); + impl->adapter_buffer = static_cast<unsigned char*>( + gpr_realloc(impl->adapter_buffer, impl->adapter_buffer_size)); } } while (status == TSI_INCOMPLETE_DATA); if (status != TSI_OK) return status; @@ -216,12 +220,14 @@ tsi_handshaker* tsi_create_adapter_handshaker(tsi_handshaker* wrapped) { impl->base.vtable = &handshaker_vtable; impl->wrapped = wrapped; impl->adapter_buffer_size = TSI_ADAPTER_INITIAL_BUFFER_SIZE; - impl->adapter_buffer = static_cast<unsigned char*>(gpr_malloc(impl->adapter_buffer_size)); + impl->adapter_buffer = + static_cast<unsigned char*>(gpr_malloc(impl->adapter_buffer_size)); return &impl->base; } tsi_handshaker* tsi_adapter_handshaker_get_wrapped(tsi_handshaker* adapter) { if (adapter == nullptr) return nullptr; - tsi_adapter_handshaker* impl = reinterpret_cast<tsi_adapter_handshaker*>(adapter); + tsi_adapter_handshaker* impl = + reinterpret_cast<tsi_adapter_handshaker*>(adapter); return impl->wrapped; } |