Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: DefaultResolver.LookupIP returns no error and nil IP address for empty string #53995

Open
davidbrink opened this issue Jul 22, 2022 · 5 comments
Labels
NeedsDecision
Milestone

Comments

@davidbrink
Copy link

davidbrink commented Jul 22, 2022

What version of Go are you using (go version)?

$ go version
go version go1.17 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/dbrink/Library/Caches/go-build"
GOENV="/Users/dbrink/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/dbrink/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/dbrink/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.17"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/dbrink/Desktop/sps/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/gb/vk5wy1jd4msc49d1vpdwf_j80015jz/T/go-build1545005800=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

https://go.dev/play/p/o1nR6WBsGQT

What did you expect to see?

An error when looking up the empty hostname.

What did you see instead?

No error and a nil IP address.

@toothrot toothrot added the NeedsInvestigation label Jul 22, 2022
@toothrot toothrot added this to the Backlog milestone Jul 22, 2022
@toothrot toothrot added NeedsDecision and removed NeedsInvestigation labels Jul 22, 2022
@seankhliao seankhliao changed the title net.DefaultResolver.LookupIP: Returns no error and nil IP address net: DefaultResolver.LookupIP returns no error and nil IP address for empty string Jul 22, 2022
@ianwoolf
Copy link
Contributor

ianwoolf commented Jul 27, 2022

DefaultResolver.LookupIP returns {nil}, nil when host is "". This is because r.internetAddrList returns the inetaddr(IPAddr{}):
https://cs.opensource.google/go/go/+/master:src/net/ipsock.go;l=284

It seems that return inetaddr(IPAddr{}) is expected. But I think the return of Resolver.LookupIP should be {}, nil, not {nil}, nil. Or return an error like net.LookupIP does.

@gopherbot
Copy link

gopherbot commented Jul 27, 2022

Change https://go.dev/cl/419734 mentions this issue: net: fix the return of Resolver.LookupIP when the host is empty

@ianwoolf
Copy link
Contributor

ianwoolf commented Jul 27, 2022

i send a wip cl and want help. I'm wondering if it's more appropriate to return an error, or just return an empty slice.

please feel free to review

@ianlancetaylor
Copy link
Contributor

ianlancetaylor commented Jul 28, 2022

Looking up an empty host name should probably return some sort of error.

@ianwoolf
Copy link
Contributor

ianwoolf commented Aug 9, 2022

Change https://go.dev/cl/419734 mentions this issue: net: fix the return of Resolver.LookupIP when the host is empty

pleas feel free to review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsDecision
Projects
None yet
Development

No branches or pull requests

5 participants