aboutsummaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorqmuntal <quimmuntal@gmail.com>2026-01-08 15:44:51 +0100
committerQuim Muntal <quimmuntal@gmail.com>2026-01-12 11:53:04 -0800
commit30d0b4026410da3486ba841bb7f13c1d9074e91d (patch)
treee038f39945d446771be825eda5d0002a2d678360 /src/net
parent5741608de26f06488e771fd7b3b35ca2ca4c93a6 (diff)
downloadgo-30d0b4026410da3486ba841bb7f13c1d9074e91d.tar.xz
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>
Diffstat (limited to 'src/net')
-rw-r--r--src/net/file_posix.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/net/file_posix.go b/src/net/file_posix.go
index 132d03e9e3..b28ff5845d 100644
--- a/src/net/file_posix.go
+++ b/src/net/file_posix.go
@@ -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: