Skip to content

Commit

Permalink
Reuse the receive buffer to print the TLS handshake error string.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamshapiro0 committed Mar 29, 2024
1 parent 3f38ab4 commit 8b2d9e0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions c/src/point_one/polaris/polaris.c
Original file line number Diff line number Diff line change
Expand Up @@ -1083,10 +1083,14 @@ static int OpenSocket(PolarisContext_t* context, const char* endpoint_url,
ret = SSL_connect(context->ssl);
if (ret != 1) {
#if !defined(P1_NO_PRINT)
char message[256];
snprintf(message, sizeof(message), "TLS handshake failed for tcp://%s:%d",
endpoint_url, endpoint_port);
P1_PrintSSLError(context, message, ret);
// Note: We intentionally reuse the receive buffer to store the error
// message to be displayed to avoid requiring additional stack here. At this
// point we're trying to open the socket, so there should be nobody actively
// using the receive buffer.
snprintf((char*)context->recv_buffer, POLARIS_RECV_BUFFER_SIZE,
"TLS handshake failed for tcp://%s:%d", endpoint_url,
endpoint_port);
P1_PrintSSLError(context, (char*)context->recv_buffer, ret);
#endif // !defined(P1_NO_PRINT)
CloseSocket(context, 1);
return POLARIS_SOCKET_ERROR;
Expand Down

0 comments on commit 8b2d9e0

Please sign in to comment.