mirror of
https://github.com/golang/go.git
synced 2026-02-07 02:09:55 +00:00
net: don't ignore getsockname errors in newFileFD
newFileFD is called when creating a net FD from an existing socket handle. That socket might not be bound yet, in which case getsockname returns a useful error that is currently ignored and replaced with a potentially misleading EPROTONOSUPPORT error later on. Updates #73696 Updates #74976 Updates #75282 Updates #75279 Updates #76537 Updates #76582 Updates #77038 Change-Id: I2a8b30ffbb037035669f65a95a923edc8b288145 Reviewed-on: https://go-review.googlesource.com/c/go/+/734820 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
parent
5741608de2
commit
30d0b40264
1 changed files with 5 additions and 1 deletions
|
|
@ -23,7 +23,11 @@ func newFileFD(f *os.File) (*netFD, error) {
|
|||
poll.CloseFunc(s)
|
||||
return nil, os.NewSyscallError("getsockopt", err)
|
||||
}
|
||||
lsa, _ := syscall.Getsockname(s)
|
||||
lsa, err := syscall.Getsockname(s)
|
||||
if err != nil {
|
||||
poll.CloseFunc(s)
|
||||
return nil, os.NewSyscallError("getsockname", err)
|
||||
}
|
||||
rsa, _ := syscall.Getpeername(s)
|
||||
switch lsa.(type) {
|
||||
case *syscall.SockaddrInet4:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue