Browse Source

Remove SSL_NEW() and SSL_FREE()

Do not overload functions from OpenSSL.
Bradley T. Hughes 6 years ago
parent
commit
e781060a52

+ 8 - 8
src/apps/relay/dtls_listener.c

@@ -288,13 +288,13 @@ static ioa_socket_handle dtls_server_input_handler(dtls_listener_relay_server_ty
 #if DTLSv1_2_SUPPORTED
 	if(get_dtls_version(ioa_network_buffer_data(nbh),
 							(int)ioa_network_buffer_get_size(nbh)) == 1) {
-		connecting_ssl = SSL_NEW(server->dtls_ctx_v1_2);
+		connecting_ssl = SSL_new(server->dtls_ctx_v1_2);
 	} else {
-		connecting_ssl = SSL_NEW(server->dtls_ctx);
+		connecting_ssl = SSL_new(server->dtls_ctx);
 	}
 #else
 	{
-		connecting_ssl = SSL_NEW(server->dtls_ctx);
+		connecting_ssl = SSL_new(server->dtls_ctx);
 	}
 #endif
 
@@ -315,7 +315,7 @@ static ioa_socket_handle dtls_server_input_handler(dtls_listener_relay_server_ty
 			SSL_set_shutdown(connecting_ssl, SSL_RECEIVED_SHUTDOWN);
 			SSL_shutdown(connecting_ssl);
 		}
-		SSL_FREE(connecting_ssl);
+		SSL_free(connecting_ssl);
 	}
 
 	return rc;
@@ -573,13 +573,13 @@ static int create_new_connected_udp_socket(
 #if DTLSv1_2_SUPPORTED
 		if(get_dtls_version(ioa_network_buffer_data(server->sm.m.sm.nd.nbh),
 							(int)ioa_network_buffer_get_size(server->sm.m.sm.nd.nbh)) == 1) {
-			connecting_ssl = SSL_NEW(server->dtls_ctx_v1_2);
+			connecting_ssl = SSL_new(server->dtls_ctx_v1_2);
 		} else {
-			connecting_ssl = SSL_NEW(server->dtls_ctx);
+			connecting_ssl = SSL_new(server->dtls_ctx);
 		}
 #else
 		{
-			connecting_ssl = SSL_NEW(server->dtls_ctx);
+			connecting_ssl = SSL_new(server->dtls_ctx);
 		}
 #endif
 
@@ -597,7 +597,7 @@ static int create_new_connected_udp_socket(
 				SSL_set_shutdown(connecting_ssl, SSL_RECEIVED_SHUTDOWN);
 				SSL_shutdown(connecting_ssl);
 			}
-			SSL_FREE(connecting_ssl);
+			SSL_free(connecting_ssl);
 			IOA_CLOSE_SOCKET(ret);
 			return -1;
 		}

+ 10 - 10
src/apps/relay/ns_ioalib_engine_impl.c

@@ -1470,7 +1470,7 @@ static void close_socket_net_data(ioa_socket_handle s)
 					log_socket_event(s, "SSL shutdown received, socket to be closed",0);
 				}
 			}
-			SSL_FREE(s->ssl);
+			SSL_free(s->ssl);
 		}
 
 		if (s->fd >= 0) {
@@ -2240,25 +2240,25 @@ static int socket_input_worker(ioa_socket_handle s)
 #if TLSv1_2_SUPPORTED
 			case TURN_TLS_v1_2:
 				if(s->e->tls_ctx_v1_2) {
-					set_socket_ssl(s,SSL_NEW(s->e->tls_ctx_v1_2));
+					set_socket_ssl(s,SSL_new(s->e->tls_ctx_v1_2));
 				}
 				break;
 #endif
 #if TLSv1_1_SUPPORTED
 			case TURN_TLS_v1_1:
 				if(s->e->tls_ctx_v1_1) {
-					set_socket_ssl(s,SSL_NEW(s->e->tls_ctx_v1_1));
+					set_socket_ssl(s,SSL_new(s->e->tls_ctx_v1_1));
 				}
 				break;
 #endif
 			case TURN_TLS_v1_0:
 				if(s->e->tls_ctx_v1_0) {
-					set_socket_ssl(s,SSL_NEW(s->e->tls_ctx_v1_0));
+					set_socket_ssl(s,SSL_new(s->e->tls_ctx_v1_0));
 				}
 				break;
 			default:
 				if(s->e->tls_ctx_ssl23) {
-					set_socket_ssl(s,SSL_NEW(s->e->tls_ctx_ssl23));
+					set_socket_ssl(s,SSL_new(s->e->tls_ctx_ssl23));
 				} else {
 					s->tobeclosed = 1;
 					return 0;
@@ -2308,25 +2308,25 @@ static int socket_input_worker(ioa_socket_handle s)
 #if TLSv1_2_SUPPORTED
 			case TURN_TLS_v1_2:
 				if(s->e->tls_ctx_v1_2) {
-					set_socket_ssl(s,SSL_NEW(s->e->tls_ctx_v1_2));
+					set_socket_ssl(s,SSL_new(s->e->tls_ctx_v1_2));
 				}
 				break;
 #endif
 #if TLSv1_1_SUPPORTED
 			case TURN_TLS_v1_1:
 				if(s->e->tls_ctx_v1_1) {
-					set_socket_ssl(s,SSL_NEW(s->e->tls_ctx_v1_1));
+					set_socket_ssl(s,SSL_new(s->e->tls_ctx_v1_1));
 				}
 				break;
 #endif
 			case TURN_TLS_v1_0:
 				if(s->e->tls_ctx_v1_0) {
-					set_socket_ssl(s,SSL_NEW(s->e->tls_ctx_v1_0));
+					set_socket_ssl(s,SSL_new(s->e->tls_ctx_v1_0));
 				}
 				break;
 			default:
 				if(s->e->tls_ctx_ssl23) {
-					set_socket_ssl(s,SSL_NEW(s->e->tls_ctx_ssl23));
+					set_socket_ssl(s,SSL_new(s->e->tls_ctx_ssl23));
 				} else {
 					s->tobeclosed = 1;
 					return 0;
@@ -3317,7 +3317,7 @@ int register_callback_on_ioa_socket(ioa_engine_handle e, ioa_socket_handle s, in
 #if TLS_SUPPORTED
 						if(!(s->ssl)) {
 							//??? how we can get to this point ???
-							set_socket_ssl(s,SSL_NEW(e->tls_ctx_ssl23));
+							set_socket_ssl(s,SSL_new(e->tls_ctx_ssl23));
 							s->bev = bufferevent_openssl_socket_new(s->e->event_base,
 											s->fd,
 											s->ssl,

+ 4 - 4
src/apps/uclient/startuclient.c

@@ -89,7 +89,7 @@ static SSL* tls_connect(ioa_socket_raw fd, ioa_addr *remote_addr, int *try_again
 
 	SSL *ssl;
 
-	ssl = SSL_NEW(root_tls_ctx[ctxtype]);
+	ssl = SSL_new(root_tls_ctx[ctxtype]);
 
 #if ALPN_SUPPORTED
 	SSL_set_alpn_protos(ssl, kALPNProtos, kALPNProtosLen);
@@ -161,7 +161,7 @@ static SSL* tls_connect(ioa_socket_raw fd, ioa_addr *remote_addr, int *try_again
 								(int)ERR_get_error(), ERR_error_string(ERR_get_error(), buf), (int)SSL_get_error(ssl, rc));
 				if(connect_cycle<MAX_TLS_CYCLES) {
 					if(try_again) {
-						SSL_FREE(ssl);
+						SSL_free(ssl);
 						*try_again = 1;
 						return NULL;
 					}
@@ -600,7 +600,7 @@ static int clnet_allocate(int verbose,
 			  int close_socket = (int)(random()%2);
 			  if(ssl && !close_socket) {
 				  SSL_shutdown(ssl);
-				  SSL_FREE(ssl);
+				  SSL_free(ssl);
 				  fd = -1;
 			  } else if(fd>=0) {
 				  close(fd);
@@ -624,7 +624,7 @@ static int clnet_allocate(int verbose,
 
 		  if(ssl) {
 			  SSL_shutdown(ssl);
-		  	  SSL_FREE(ssl);
+		  	  SSL_free(ssl);
 		  } else if(fd>=0) {
 		  	  close(fd);
 		  }

+ 4 - 4
src/apps/uclient/uclient.c

@@ -142,7 +142,7 @@ static void uc_delete_session_elem_data(app_ur_session* cdi) {
 	      SSL_shutdown(cdi->pinfo.tcp_conn[i]->tcp_data_ssl);
 	    }
 	    if(cdi->pinfo.tcp_conn[i]->tcp_data_ssl) {
-	      SSL_FREE(cdi->pinfo.tcp_conn[i]->tcp_data_ssl);
+	      SSL_free(cdi->pinfo.tcp_conn[i]->tcp_data_ssl);
 	    }
 	    if(cdi->pinfo.tcp_conn[i]->tcp_data_fd>=0) {
 	    	socket_closesocket(cdi->pinfo.tcp_conn[i]->tcp_data_fd);
@@ -166,7 +166,7 @@ static void uc_delete_session_elem_data(app_ur_session* cdi) {
 	    }
     }
     if(cdi->pinfo.ssl) {
-	    SSL_FREE(cdi->pinfo.ssl);
+	    SSL_free(cdi->pinfo.ssl);
     }
     if(cdi->pinfo.fd>=0) {
     	socket_closesocket(cdi->pinfo.fd);
@@ -1022,7 +1022,7 @@ static int start_client(const char *remote_address, int port,
 		   clnet_info_rtcp, &chnum_rtcp);
 		   
   if(clnet_info_probe.ssl) {
-  	SSL_FREE(clnet_info_probe.ssl);
+  	SSL_free(clnet_info_probe.ssl);
   	clnet_info_probe.fd = -1;
   } else if(clnet_info_probe.fd != -1) {
 	  socket_closesocket(clnet_info_probe.fd);
@@ -1126,7 +1126,7 @@ static int start_c2c(const char *remote_address, int port,
 		       clnet_info2_rtcp, &chnum2_rtcp);
 		       
   if(clnet_info_probe.ssl) {
-	SSL_FREE(clnet_info_probe.ssl);
+	SSL_free(clnet_info_probe.ssl);
 	clnet_info_probe.fd = -1;
   } else if(clnet_info_probe.fd != -1) {
 	  socket_closesocket(clnet_info_probe.fd);

+ 0 - 5
src/ns_turn_defs.h

@@ -125,19 +125,14 @@ static inline u64bits _ioa_ntoh64(u64bits v)
 #define debug_ptr_del(ptr) debug_ptr_del_func((ptr),__FUNCTION__,__LINE__)
 #define tm_print() tm_print_func()
 
-#define SSL_NEW(ctx) ((SSL*)debug_ptr_add(SSL_new(ctx)))
-
 #else
 
 #define debug_ptr_add(ptr)
 #define debug_ptr_del(ptr)
 #define tm_print() 
 
-#define SSL_NEW(ctx) SSL_new(ctx)
-
 #endif
 
-#define SSL_FREE(ssl) do { debug_ptr_del(ssl); SSL_free(ssl); ssl = NULL; } while(0)
 #define BUFFEREVENT_FREE(be) do { if(be) { debug_ptr_del(be); bufferevent_flush(be,EV_READ|EV_WRITE,BEV_FLUSH); bufferevent_disable(be,EV_READ|EV_WRITE); bufferevent_free(be); be = NULL;} } while(0)
 
 #define turn_time() ((turn_time_t)time(NULL))