From ab0d633d5b94d016e2887cdee928ddf8a888dfa6 Mon Sep 17 00:00:00 2001 From: David Garske Date: Wed, 10 Jan 2024 17:26:55 -0800 Subject: [PATCH] Peer review cleanups 2. --- tls/client-tls-cryptocb.c | 12 ++++++------ tls/server-tls-cryptocb.c | 13 ++++++------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/tls/client-tls-cryptocb.c b/tls/client-tls-cryptocb.c index e835c4c2..03a91c81 100644 --- a/tls/client-tls-cryptocb.c +++ b/tls/client-tls-cryptocb.c @@ -178,7 +178,9 @@ int main(int argc, char** argv) wolfSSL_CTX_SetDevId(ctx, devId); #if 0 - /* Example: "TLS13-AES256-GCM-SHA384", "TLS13-AES128-GCM-SHA256" or "TLS13-CHACHA20-POLY1305-SHA256" */ + /* Examples: "TLS13-AES256-GCM-SHA384", + * "TLS13-AES128-GCM-SHA256" or + * "TLS13-CHACHA20-POLY1305-SHA256" */ wolfSSL_CTX_set_cipher_list(ctx, "TLS13-AES256-GCM-SHA384"); #endif @@ -243,12 +245,10 @@ int main(int argc, char** argv) exit: /* Cleanup and return */ + wolfSSL_free(ssl); /* Free the wolfSSL object */ if (sockfd != SOCKET_INVALID) - close(sockfd); /* Close the connection to the server */ - if (ssl != NULL) - wolfSSL_free(ssl); /* Free the wolfSSL object */ - if (ctx != NULL) - wolfSSL_CTX_free(ctx); /* Free the wolfSSL context object */ + close(sockfd); /* Close the connection to the server */ + wolfSSL_CTX_free(ctx); /* Free the wolfSSL context object */ wolfSSL_Cleanup(); /* Cleanup the wolfSSL environment */ #else diff --git a/tls/server-tls-cryptocb.c b/tls/server-tls-cryptocb.c index 5c2d2ae1..3d5dc53c 100644 --- a/tls/server-tls-cryptocb.c +++ b/tls/server-tls-cryptocb.c @@ -142,7 +142,9 @@ int main(int argc, char** argv) WOLFSSL_VERIFY_PEER | WOLFSSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL); #if 0 - /* Example: "TLS13-AES256-GCM-SHA384", "TLS13-AES128-GCM-SHA256" or "TLS13-CHACHA20-POLY1305-SHA256" */ + /* Examples: "TLS13-AES256-GCM-SHA384", + * "TLS13-AES128-GCM-SHA256" or + * "TLS13-CHACHA20-POLY1305-SHA256" */ wolfSSL_CTX_set_cipher_list(ctx, "TLS13-AES256-GCM-SHA384"); #endif @@ -238,7 +240,6 @@ int main(int argc, char** argv) } - /* Write our reply into buff */ memset(buff, 0, sizeof(buff)); memcpy(buff, reply, strlen(reply)); @@ -264,14 +265,12 @@ int main(int argc, char** argv) exit: /* Cleanup and return */ - if (ssl) - wolfSSL_free(ssl); /* Free the wolfSSL object */ + wolfSSL_free(ssl); /* Free the wolfSSL object */ if (connd != SOCKET_INVALID) - close(connd); /* Close the connection to the client */ + close(connd); /* Close the connection to the client */ if (sockfd != SOCKET_INVALID) close(sockfd); /* Close the socket listening for clients */ - if (ctx) - wolfSSL_CTX_free(ctx); /* Free the wolfSSL context object */ + wolfSSL_CTX_free(ctx); /* Free the wolfSSL context object */ wolfSSL_Cleanup(); /* Cleanup the wolfSSL environment */ #else printf("Please configure wolfSSL with --enable-cryptocb and try again\n");