File 0414-ssl-Handle-that-inet-getopts-may-return-ok.patch of Package erlang
From 392771c1e63b330dc1148e1569ce797b40b99c90 Mon Sep 17 00:00:00 2001
From: Ingela Anderton Andin <ingela@erlang.org>
Date: Wed, 2 Aug 2023 08:44:00 +0200
Subject: [PATCH] ssl: Handle that inet:getopts may return {ok, []}
If the standard C library call getsockopt(2) returns an error for an option -
then no return value is created for that option. There is not check about
the socket's state in the call chain; if the inet_drv port is still open,
then the getsockopt(2) call is executed.
So it should be possible that inet:getsockopt(Port, [sndbuf]) (or recbuf),
for a Port that is not dead yet but the underlying socket is closed,
may return {ok,[]}.
Closes #7506
---
lib/ssl/src/ssl_gen_statem.erl | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/ssl/src/ssl_gen_statem.erl b/lib/ssl/src/ssl_gen_statem.erl
index 006ad88c26..1a4d380aa0 100644
--- a/lib/ssl/src/ssl_gen_statem.erl
+++ b/lib/ssl/src/ssl_gen_statem.erl
@@ -2050,6 +2050,8 @@ get_socket_opts(Connection, Transport, Socket, [Tag | Tags], SockOpts, Acc) ->
case Connection:getopts(Transport, Socket, [Tag]) of
{ok, [Opt]} ->
get_socket_opts(Connection, Transport, Socket, Tags, SockOpts, [Opt | Acc]);
+ {ok, []} ->
+ get_socket_opts(Connection, Transport, Socket, Tags, SockOpts, Acc);
{error, Reason} ->
{error, {options, {socket_options, Tag, Reason}}}
end;
--
2.35.3