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.IP(req.RemoteAddr) instead of net.ParseIP(req.RemoteAddr) #1482

Open
dgryski opened this issue Dec 15, 2023 · 0 comments
Open

net.IP(req.RemoteAddr) instead of net.ParseIP(req.RemoteAddr) #1482

dgryski opened this issue Dec 15, 2023 · 0 comments

Comments

@dgryski
Copy link

dgryski commented Dec 15, 2023

package main

import (
	"net"
	"net/http"
)

func main() {
	var req http.Request
	_ = net.IP(req.RemoteAddr) // what was typed
	_ = net.ParseIP(req.RemoteAddr) // what what intended
}

Because net.IP's underlying type is a []byte, the net.IP conversion from req.RemoteAddr (which is a string) succeeds, but of course doesn't end up with the expected result.

@dgryski dgryski added the needs-triage Newly filed issue that needs triage label Dec 15, 2023
@dominikh dominikh added new-check and removed needs-triage Newly filed issue that needs triage labels Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants