From a2471c154b72c0d154e881379fd1ab79e80b9c70 Mon Sep 17 00:00:00 2001 From: Claude Jordan <45038457+cljord@users.noreply.github.com> Date: Mon, 31 May 2021 23:35:19 +0200 Subject: [PATCH] Add check_open(sock) to _sockname (#41000) Not checking could lead to a segfault on closed TCPSockets in getpeername Fixes #40993 (cherry picked from commit 28e30a395318da5892e73c0e7b4ad6dbb0a14199) --- stdlib/Sockets/src/Sockets.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/Sockets/src/Sockets.jl b/stdlib/Sockets/src/Sockets.jl index 99dab5e61e01e4..1e5b90cdda3902 100644 --- a/stdlib/Sockets/src/Sockets.jl +++ b/stdlib/Sockets/src/Sockets.jl @@ -806,6 +806,7 @@ socket is connected to. Valid only for connected TCP sockets. getpeername(sock::TCPSocket) = _sockname(sock, false) function _sockname(sock, self=true) + sock.status == StatusInit || check_open(sock) rport = Ref{Cushort}(0) raddress = zeros(UInt8, 16) rfamily = Ref{Cuint}(0)