]> Cypherpunks repositories - gostls13.git/commit
net: in (*netFD).dial, use the passed in local address if getsockname fails
authorBryan C. Mills <bcmills@google.com>
Tue, 23 Nov 2021 15:27:30 +0000 (10:27 -0500)
committerBryan Mills <bcmills@google.com>
Tue, 7 Dec 2021 02:31:12 +0000 (02:31 +0000)
commite07b02ff87af594a68484dcb1e3a78d1c39abc56
tree3b5c45daf55f78d2ee2c9336346df4b23c0077d6
parent0eb39ca1f0ca118e78648fb6844d35d0a96e5eee
net: in (*netFD).dial, use the passed in local address if getsockname fails

'man getsockname' lists a number of possible failure modes, including
ENOBUFS (for resource exhaustion) and EBADF (which we could possibly
see in the event of a bug or race condition elsewhere in the program).

If getsockname fails for an explicit user-provided local address, the
user is probably not expecting LocalAddr on the returned net.Conn to
return nil. This may or may not fix #34611, but should at least help
us diagnose it more clearly.

While we're add it, also add more nil-checking logic in the test based
on the stack traces posted to
https://golang.org/issue/34611#issuecomment-975923748.

For #34611

Change-Id: Iba870b96787811e4b9959b74ef648afce9316602
Reviewed-on: https://go-review.googlesource.com/c/go/+/366536
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/net/server_test.go
src/net/sock_posix.go