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

(cherry picked from commit 28e30a3)
  • Loading branch information
cljord authored and staticfloat committed Dec 22, 2022
1 parent 8d0a0ea commit a2471c1
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 a2471c1

Please sign in to comment.