Skip to content

Commit

Permalink
Add check_open(sock) to _sockname (#41000)
Browse files Browse the repository at this point in the history
Not checking could lead to a segfault on closed TCPSockets in getpeername

Fixes #40993
  • Loading branch information
cljord authored May 31, 2021
1 parent 0b16e8f commit 28e30a3
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions stdlib/Sockets/src/Sockets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 28e30a3

Please sign in to comment.