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: consider rejecting null byte in LookupHost (and similar) on all platforms consistently #37044

Open
dmitshur opened this issue Feb 5, 2020 · 0 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@dmitshur
Copy link
Contributor

dmitshur commented Feb 5, 2020

This is a followup to issues #31597 and #37031.

It is my current understanding that no valid host can contain the null byte ('\x00'), so any such string input is not valid.

net.LookupHost currently operates differently when given an input that contains a null byte. For example, for net.LookupHost("foo\x00bar"):

It seems that the getaddrinfo C API used on many platforms accepts a null-terminated C-style string and cannot be given a string containing null bytes.

As @ianlancetaylor points out, in the syscall package we reject strings with embedded null bytes, since they won't work with system calls that expect C strings, see syscall.ByteSliceFromString.

Perhaps this is an opportunity to make Go operate more consistently on such inputs on all platforms by reporting an error when the name string contains a null byte. There may be more functions in net that could benefit from this input validation, but to be able to make this change, we need to be confident that this change won't break correct Go programs.

/cc @FiloSottile @ianlancetaylor @mikioh @bradfitz

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 5, 2020
@dmitshur dmitshur added this to the Backlog milestone Feb 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

1 participant