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

Windows: DialIP and ListenIP silently return incorrect data on errors #2216

Closed
nerdatmath opened this issue Sep 1, 2011 · 2 comments
Closed

Comments

@nerdatmath
Copy link
Contributor

Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull", "hg update default", rebuild, and
retry
what you did to
reproduce the problem.  Thanks.

What steps will reproduce the problem?

1. Compile and run (as a Windows Administrator) the following code
package main
import "net"
import "fmt"
func main() {
 _, err := net.ListenIP("ip4:blah", nil)
 fmt.Println(err)
}

What is the expected output?
"dial ip4: protocol not supported"


What do you see instead?
"<nil>"

Which compiler are you using (5g, 6g, 8g, gccgo)?
8g

Which operating system are you using?
Windows XP, SP2

Which revision are you using?  (hg identify)
gomingw, release "gowin32_release.r59"

Please provide any additional information below.
This actually reflects a bug in go/src/pkg/net/iprawsock.go, in which splitNetProto()
will never set err to anything, even when the protocol passed cannot be found. Instead,
for "ip4:blah" it returns ("ip4", 0, nil). On Linux, this results in
an error from socket() because there is no supported IP protocol number 0. On Windows
however, the socket() call fails, but with an invalid protocol number which ends up
creating weird packets on the network. This contributes to issue #2215, where no textual
protocols can be successfully looked up, so even "ip4:icmp" results in a
socket opened with protocol 0.
@alexbrainman
Copy link
Member

Comment 1:

I think you are correct. splitNetProto needs to be fixed. You are welcome to send a fix:
http://golang.org/doc/contribute.html.

Labels changed: added packagebug.

Owner changed to @alexbrainman.

Status changed to Accepted.

@alexbrainman
Copy link
Member

Comment 2:

This issue was closed by revision 059c68b.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants