Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
0973-ssl-Remove-is_port-guards-for-sockets.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0973-ssl-Remove-is_port-guards-for-sockets.patch of Package erlang
From eb288918354de215c2c1b3f38feedb763cd97447 Mon Sep 17 00:00:00 2001 From: Ingela Anderton Andin <ingela@erlang.org> Date: Tue, 26 Apr 2022 11:39:05 +0200 Subject: [PATCH] ssl: Remove is_port guards for sockets Sockets may have other types then port, remove these checks as it violates socket abstraction and breaks the code for gen_tcp sockets with new inet_backend. Closes #5930 --- lib/ssl/src/ssl.erl | 48 +++++++++++++++------------------ lib/ssl/test/dtls_api_SUITE.erl | 2 +- lib/ssl/test/tls_api_SUITE.erl | 14 +++++----- 3 files changed, 28 insertions(+), 36 deletions(-) diff --git a/lib/ssl/src/ssl.erl b/lib/ssl/src/ssl.erl index e61ffa6cc9..2b88568927 100644 --- a/lib/ssl/src/ssl.erl +++ b/lib/ssl/src/ssl.erl @@ -849,7 +849,7 @@ send(#sslsocket{pid = {dtls,_}}, _) -> {error,enotconn}; %% Emulate connection behaviour send(#sslsocket{pid = {ListenSocket, #config{transport_info = Info}}}, Data) -> Transport = element(1, Info), - Transport:send(ListenSocket, Data). %% {error,enotconn} + tls_socket:send(Transport, ListenSocket, Data). %% {error,enotconn} %%-------------------------------------------------------------------- %% @@ -877,7 +877,7 @@ recv(#sslsocket{pid = [Pid|_]}, Length, Timeout) when is_pid(Pid), recv(#sslsocket{pid = {dtls,_}}, _, _) -> {error,enotconn}; recv(#sslsocket{pid = {Listen, - #config{transport_info = Info}}},_,_) when is_port(Listen)-> + #config{transport_info = Info}}},_,_) -> Transport = element(1, Info), Transport:recv(Listen, 0). %% {error,enotconn} @@ -897,12 +897,10 @@ controlling_process(#sslsocket{pid = {dtls, _}}, ok; %% Meaningless but let it be allowed to conform with TLS controlling_process(#sslsocket{pid = {Listen, #config{transport_info = {Transport,_,_,_,_}}}}, - NewOwner) when is_port(Listen), - is_pid(NewOwner) -> - %% Meaningless but let it be allowed to conform with normal sockets + NewOwner) when is_pid(NewOwner) -> + %% Meaningless but let it be allowed to conform with normal sockets Transport:controlling_process(Listen, NewOwner). - %%-------------------------------------------------------------------- -spec connection_information(SslSocket) -> {ok, Result} | {error, reason()} when SslSocket :: sslsocket(), @@ -917,11 +915,8 @@ connection_information(#sslsocket{pid = [Pid|_]}) when is_pid(Pid) -> Error -> Error end; -connection_information(#sslsocket{pid = {Listen, _}}) when is_port(Listen) -> - {error, enotconn}; -connection_information(#sslsocket{pid = {dtls,_}}) -> - {error,enotconn}. - +connection_information(#sslsocket{pid = {_Listen, #config{}}}) -> + {error, enotconn}. %%-------------------------------------------------------------------- -spec connection_information(SslSocket, Items) -> {ok, Result} | {error, reason()} when SslSocket :: sslsocket(), @@ -975,7 +970,7 @@ peercert(#sslsocket{pid = [Pid|_]}) when is_pid(Pid) -> end; peercert(#sslsocket{pid = {dtls, _}}) -> {error, enotconn}; -peercert(#sslsocket{pid = {Listen, _}}) when is_port(Listen) -> +peercert(#sslsocket{pid = {_Listen, #config{}}}) -> {error, enotconn}. %%-------------------------------------------------------------------- @@ -1247,12 +1242,14 @@ getstat(Socket) -> %% %% Description: Get one or more statistic options for a socket. %%-------------------------------------------------------------------- -getstat(#sslsocket{pid = {dtls, #config{transport_info = {Transport, _, _, _, _}, +getstat(#sslsocket{pid = {dtls, #config{transport_info = Info, dtls_handler = {Listener, _}}}}, Options) when is_list(Options) -> + Transport = element(1, Info), dtls_socket:getstat(Transport, Listener, Options); -getstat(#sslsocket{pid = {Listen, #config{transport_info = {Transport, _, _, _, _}}}}, - Options) when is_port(Listen), is_list(Options) -> +getstat(#sslsocket{pid = {Listen, #config{transport_info = Info}}}, + Options) when is_list(Options) -> + Transport = element(1, Info), tls_socket:getstat(Transport, Listen, Options); getstat(#sslsocket{pid = [Pid|_], fd = {Transport, Socket, _, _}}, Options) when is_pid(Pid), is_list(Options) -> @@ -1268,12 +1265,11 @@ getstat(#sslsocket{pid = [Pid|_], fd = {Transport, Socket, _}}, %% %% Description: Same as gen_tcp:shutdown/2 %%-------------------------------------------------------------------- -shutdown(#sslsocket{pid = {Listen, #config{transport_info = Info}}}, - How) when is_port(Listen) -> - Transport = element(1, Info), - Transport:shutdown(Listen, How); -shutdown(#sslsocket{pid = {dtls,_}},_) -> +shutdown(#sslsocket{pid = {dtls, #config{}}},_) -> {error, enotconn}; +shutdown(#sslsocket{pid = {Listen, #config{transport_info = Info}}}, How) -> + Transport = element(1, Info), + Transport:shutdown(Listen, How); shutdown(#sslsocket{pid = [Pid|_]}, How) when is_pid(Pid) -> ssl_gen_statem:shutdown(Pid, How). @@ -1286,10 +1282,11 @@ shutdown(#sslsocket{pid = [Pid|_]}, How) when is_pid(Pid) -> %% %% Description: Same as inet:sockname/1 %%-------------------------------------------------------------------- -sockname(#sslsocket{pid = {Listen, #config{transport_info = {Transport,_,_,_,_}}}}) when is_port(Listen) -> - tls_socket:sockname(Transport, Listen); sockname(#sslsocket{pid = {dtls, #config{dtls_handler = {Pid, _}}}}) -> dtls_packet_demux:sockname(Pid); +sockname(#sslsocket{pid = {Listen, #config{transport_info = Info}}}) -> + Transport = element(1, Info), + tls_socket:sockname(Transport, Listen); sockname(#sslsocket{pid = [Pid|_], fd = {Transport, Socket,_}}) when is_pid(Pid) -> dtls_socket:sockname(Transport, Socket); sockname(#sslsocket{pid = [Pid| _], fd = {Transport, Socket,_,_}}) when is_pid(Pid) -> @@ -1348,10 +1345,9 @@ renegotiate(#sslsocket{pid = [Pid |_]}) when is_pid(Pid) -> tls_dtls_connection:renegotiation(Pid); renegotiate(#sslsocket{pid = {dtls,_}}) -> {error, enotconn}; -renegotiate(#sslsocket{pid = {Listen,_}}) when is_port(Listen) -> +renegotiate(#sslsocket{pid = {_Listen, #config{}}}) -> {error, enotconn}. - %%--------------------------------------------------------------- -spec update_keys(SslSocket, Type) -> ok | {error, reason()} when SslSocket :: sslsocket(), @@ -1387,9 +1383,7 @@ update_keys(_, Type) -> prf(#sslsocket{pid = [Pid|_]}, Secret, Label, Seed, WantedLength) when is_pid(Pid) -> tls_dtls_connection:prf(Pid, Secret, Label, Seed, WantedLength); -prf(#sslsocket{pid = {dtls,_}}, _,_,_,_) -> - {error, enotconn}; -prf(#sslsocket{pid = {Listen,_}}, _,_,_,_) when is_port(Listen) -> +prf(#sslsocket{pid = {_Listen, #config{}}}, _,_,_,_) -> {error, enotconn}. %%-------------------------------------------------------------------- diff --git a/lib/ssl/test/tls_api_SUITE.erl b/lib/ssl/test/tls_api_SUITE.erl index 9bc1529a4a..4dd32ab0dc 100644 --- a/lib/ssl/test/tls_api_SUITE.erl +++ b/lib/ssl/test/tls_api_SUITE.erl @@ -1223,13 +1221,13 @@ tls_downgrade_result(Socket, Pid) -> end. tls_shutdown_result(Socket, server) -> - ssl:send(Socket, "Hej"), + ok = ssl:send(Socket, "Hej"), ok = ssl:shutdown(Socket, write), {ok, "Hej hopp"} = ssl:recv(Socket, 8), ok; tls_shutdown_result(Socket, client) -> - ssl:send(Socket, "Hej hopp"), + ok = ssl:send(Socket, "Hej hopp"), ok = ssl:shutdown(Socket, write), {ok, "Hej"} = ssl:recv(Socket, 3), ok. -- 2.34.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor