@@ -3700,6 +3700,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
37003700 if (wolfSSL_UseOCSPStapling (ssl , WOLFSSL_CSR_OCSP ,
37013701 WOLFSSL_CSR_OCSP_USE_NONCE ) != WOLFSSL_SUCCESS ) {
37023702 wolfSSL_free (ssl ); ssl = NULL ;
3703+ CloseSocket (sockfd );
37033704 wolfSSL_CTX_free (ctx ); ctx = NULL ;
37043705 err_sys ("UseCertificateStatusRequest failed" );
37053706 }
@@ -3711,6 +3712,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
37113712 WOLFSSL_CSR2_OCSP , WOLFSSL_CSR2_OCSP_USE_NONCE )
37123713 != WOLFSSL_SUCCESS ) {
37133714 wolfSSL_free (ssl ); ssl = NULL ;
3715+ CloseSocket (sockfd );
37143716 wolfSSL_CTX_free (ctx ); ctx = NULL ;
37153717 err_sys ("UseCertificateStatusRequest failed" );
37163718 }
@@ -3720,6 +3722,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
37203722 WOLFSSL_CSR2_OCSP_MULTI , 0 )
37213723 != WOLFSSL_SUCCESS ) {
37223724 wolfSSL_free (ssl ); ssl = NULL ;
3725+ CloseSocket (sockfd );
37233726 wolfSSL_CTX_free (ctx ); ctx = NULL ;
37243727 err_sys ("UseCertificateStatusRequest failed" );
37253728 }
@@ -3748,6 +3751,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
37483751 tcp_connect (& sockfd , host , port , dtlsUDP , dtlsSCTP , ssl );
37493752 if (wolfSSL_set_fd (ssl , sockfd ) != WOLFSSL_SUCCESS ) {
37503753 wolfSSL_free (ssl ); ssl = NULL ;
3754+ CloseSocket (sockfd );
37513755 wolfSSL_CTX_free (ctx ); ctx = NULL ;
37523756 err_sys ("error in setting fd" );
37533757 }
@@ -3763,6 +3767,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
37633767 if (doSTARTTLS ) {
37643768 if (StartTLS_Init (& sockfd ) != WOLFSSL_SUCCESS ) {
37653769 wolfSSL_free (ssl ); ssl = NULL ;
3770+ CloseSocket (sockfd );
37663771 wolfSSL_CTX_free (ctx ); ctx = NULL ;
37673772 err_sys ("error during STARTTLS protocol" );
37683773 }
@@ -3776,17 +3781,20 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
37763781
37773782 if (wolfSSL_EnableCRL (ssl , WOLFSSL_CRL_CHECKALL ) != WOLFSSL_SUCCESS ) {
37783783 wolfSSL_free (ssl ); ssl = NULL ;
3784+ CloseSocket (sockfd );
37793785 wolfSSL_CTX_free (ctx ); ctx = NULL ;
37803786 err_sys ("can't enable crl check" );
37813787 }
37823788 if (wolfSSL_LoadCRL (ssl , crlPemDir , WOLFSSL_FILETYPE_PEM , 0 )
37833789 != WOLFSSL_SUCCESS ) {
37843790 wolfSSL_free (ssl ); ssl = NULL ;
3791+ CloseSocket (sockfd );
37853792 wolfSSL_CTX_free (ctx ); ctx = NULL ;
37863793 err_sys ("can't load crl, check crlfile and date validity" );
37873794 }
37883795 if (wolfSSL_SetCRL_Cb (ssl , CRL_CallBack ) != WOLFSSL_SUCCESS ) {
37893796 wolfSSL_free (ssl ); ssl = NULL ;
3797+ CloseSocket (sockfd );
37903798 wolfSSL_CTX_free (ctx ); ctx = NULL ;
37913799 err_sys ("can't set crl callback" );
37923800 }
@@ -3796,6 +3804,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
37963804 if (scr ) {
37973805 if (wolfSSL_UseSecureRenegotiation (ssl ) != WOLFSSL_SUCCESS ) {
37983806 wolfSSL_free (ssl ); ssl = NULL ;
3807+ CloseSocket (sockfd );
37993808 wolfSSL_CTX_free (ctx ); ctx = NULL ;
38003809 err_sys ("can't enable secure renegotiation" );
38013810 }
@@ -3948,13 +3957,15 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
39483957 size = wolfSSL_get_client_random (NULL , NULL , 0 );
39493958 if (size == 0 ) {
39503959 wolfSSL_free (ssl ); ssl = NULL ;
3960+ CloseSocket (sockfd );
39513961 wolfSSL_CTX_free (ctx ); ctx = NULL ;
39523962 err_sys ("error getting client random buffer size" );
39533963 }
39543964
39553965 rnd = (byte * )XMALLOC (size , NULL , DYNAMIC_TYPE_TMP_BUFFER );
39563966 if (rnd == NULL ) {
39573967 wolfSSL_free (ssl ); ssl = NULL ;
3968+ CloseSocket (sockfd );
39583969 wolfSSL_CTX_free (ctx ); ctx = NULL ;
39593970 err_sys ("error creating client random buffer" );
39603971 }
@@ -3963,6 +3974,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
39633974 if (size == 0 ) {
39643975 XFREE (rnd , NULL , DYNAMIC_TYPE_TMP_BUFFER );
39653976 wolfSSL_free (ssl ); ssl = NULL ;
3977+ CloseSocket (sockfd );
39663978 wolfSSL_CTX_free (ctx ); ctx = NULL ;
39673979 err_sys ("error getting client random buffer" );
39683980 }
@@ -4001,6 +4013,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
40014013 if (XSTRCMP (starttlsProt , "smtp" ) == 0 ) {
40024014 if (SMTP_Shutdown (ssl , wc_shutdown ) != WOLFSSL_SUCCESS ) {
40034015 wolfSSL_free (ssl ); ssl = NULL ;
4016+ CloseSocket (sockfd );
40044017 wolfSSL_CTX_free (ctx ); ctx = NULL ;
40054018 err_sys ("error closing STARTTLS connection" );
40064019 }
@@ -4115,6 +4128,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
41154128 LOG_ERROR ("wolfSSL_Rehandshake error %d, %s\n" , err ,
41164129 wolfSSL_ERR_error_string (err , buffer ));
41174130 wolfSSL_free (ssl ); ssl = NULL ;
4131+ CloseSocket (sockfd );
41184132 wolfSSL_CTX_free (ctx ); ctx = NULL ;
41194133 err_sys ("non-blocking wolfSSL_Rehandshake failed" );
41204134 }
@@ -4145,6 +4159,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
41454159 printf ("err = %d, %s\n" , err ,
41464160 wolfSSL_ERR_error_string (err , buffer ));
41474161 wolfSSL_free (ssl ); ssl = NULL ;
4162+ CloseSocket (sockfd );
41484163 wolfSSL_CTX_free (ctx ); ctx = NULL ;
41494164 err_sys ("wolfSSL_Rehandshake failed" );
41504165 }
@@ -4174,6 +4189,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
41744189 printf ("err = %d, %s\n" , err ,
41754190 wolfSSL_ERR_error_string (err , buffer ));
41764191 wolfSSL_free (ssl ); ssl = NULL ;
4192+ CloseSocket (sockfd );
41774193 wolfSSL_CTX_free (ctx ); ctx = NULL ;
41784194 err_sys ("wolfSSL_SecureResume failed" );
41794195 }
@@ -4210,6 +4226,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
42104226 if (exitWithRet ) {
42114227 ((func_args * )args )-> return_code = err ;
42124228 wolfSSL_free (ssl ); ssl = NULL ;
4229+ CloseSocket (sockfd );
42134230 wolfSSL_CTX_free (ctx ); ctx = NULL ;
42144231 goto exit ;
42154232 }
@@ -4229,6 +4246,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
42294246 if (exitWithRet && (err != 0 )) {
42304247 ((func_args * )args )-> return_code = err ;
42314248 wolfSSL_free (ssl ); ssl = NULL ;
4249+ CloseSocket (sockfd );
42324250 wolfSSL_CTX_free (ctx ); ctx = NULL ;
42334251 goto exit ;
42344252 }
@@ -4346,6 +4364,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
43464364 tcp_connect (& sockfd , host , port , dtlsUDP , dtlsSCTP , sslResume );
43474365 if (wolfSSL_set_fd (sslResume , sockfd ) != WOLFSSL_SUCCESS ) {
43484366 wolfSSL_free (sslResume ); sslResume = NULL ;
4367+ CloseSocket (sockfd );
43494368 wolfSSL_CTX_free (ctx ); ctx = NULL ;
43504369 err_sys ("error in setting fd" );
43514370 }
@@ -4366,6 +4385,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
43664385 if (scr ) {
43674386 if (wolfSSL_UseSecureRenegotiation (sslResume ) != WOLFSSL_SUCCESS ) {
43684387 wolfSSL_free (sslResume ); sslResume = NULL ;
4388+ CloseSocket (sockfd );
43694389 wolfSSL_CTX_free (ctx ); ctx = NULL ;
43704390 err_sys ("can't enable secure renegotiation" );
43714391 }
@@ -4440,6 +4460,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
44404460 LOG_ERROR ("wolfSSL_connect resume error %d, %s\n" , err ,
44414461 wolfSSL_ERR_error_string (err , buffer ));
44424462 wolfSSL_free (sslResume ); sslResume = NULL ;
4463+ CloseSocket (sockfd );
44434464 wolfSSL_CTX_free (ctx ); ctx = NULL ;
44444465 err_sys ("wolfSSL_connect resume failed" );
44454466 }
@@ -4488,6 +4509,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
44884509 LOG_ERROR ("err = %d, %s\n" , err ,
44894510 wolfSSL_ERR_error_string (err , buffer ));
44904511 wolfSSL_free (sslResume ); sslResume = NULL ;
4512+ CloseSocket (sockfd );
44914513 wolfSSL_CTX_free (ctx ); ctx = NULL ;
44924514 err_sys ("wolfSSL_Rehandshake failed" );
44934515 }
@@ -4502,6 +4524,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
45024524 LOG_ERROR ("err = %d, %s\n" , err ,
45034525 wolfSSL_ERR_error_string (err , buffer ));
45044526 wolfSSL_free (sslResume ); sslResume = NULL ;
4527+ CloseSocket (sockfd );
45054528 wolfSSL_CTX_free (ctx ); ctx = NULL ;
45064529 err_sys ("wolfSSL_SecureResume failed" );
45074530 }
0 commit comments