Skip to content

Commit

Permalink
Add check_open(sock) to _sockname (JuliaLang#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 JuliaLang#40993
  • Loading branch information
cljord authored and Amit Shirodkar committed Jun 9, 2021
1 parent edd39d9 commit df16c4c
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 df16c4c

Please sign in to comment.