mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-08 13:40:51 +02:00
IDE examples: fix ssl double-free and unsafe connd close in servers
This commit is contained in:
@@ -406,6 +406,7 @@ WOLFSSL_ESP_TASK tls_smp_server_task(void *args)
|
||||
ESP_LOGI(TAG, "Done! Cleanup...");
|
||||
/* Cleanup after this connection */
|
||||
wolfSSL_free(ssl); /* Free the wolfSSL object */
|
||||
ssl = NULL;
|
||||
close(connd); /* Close the connection to the client */
|
||||
#ifdef WOLFSSL_EXAMPLE_VERBOSITY
|
||||
ESP_LOGI(TAG, "Stack used: %d\n",
|
||||
|
||||
@@ -246,7 +246,7 @@ static int TLS_ECDH_callback(WOLFSSL* ssl, struct ecc_key* otherKey,
|
||||
int main()
|
||||
{
|
||||
int sockfd;
|
||||
int connd = 0;
|
||||
int connd = -1;
|
||||
struct sockaddr_in servAddr;
|
||||
struct sockaddr_in clientAddr;
|
||||
socklen_t size = sizeof(clientAddr);
|
||||
@@ -379,7 +379,8 @@ int main()
|
||||
end:
|
||||
/* Cleanup after this connection */
|
||||
wolfSSL_free(ssl); /* Free the wolfSSL object */
|
||||
close(connd); /* Close the connection to the client */
|
||||
if (connd != -1)
|
||||
close(connd); /* Close the connection to the client */
|
||||
wc_ecc_free(&blackKey);
|
||||
|
||||
printf("Shutdown complete\n");
|
||||
|
||||
Reference in New Issue
Block a user