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

DNS resolution fails if no newline at the end of resolv.conf #686

Closed
gopherbot opened this issue Mar 21, 2010 · 3 comments
Closed

DNS resolution fails if no newline at the end of resolv.conf #686

gopherbot opened this issue Mar 21, 2010 · 3 comments

Comments

@gopherbot
Copy link
Contributor

by bortzmeyer:

What steps will reproduce the problem?
1. http.Get(anyurl) (or anything which uses Dial)
2. compile
3. run

What is the expected output? What do you see instead?
I expect a nil error

But I get:

Error Get http://data.keolis-rennes.com/xml/: dial tcp
data.keolis-rennes.com:http: lookup data.keolis-rennes.com.: no DNS servers


What is your $GOOS?  $GOARCH?

GOOS=linux
GOARCH=386
GOROOT=/local/go

Which revision are you using?  (hg identify)

ef7417009743 tip


Please provide any additional information below.

All the other programs (dig, ping, wget) work fine with this
resolv.conf.But Go, instead of using the OS routines, implements its own
name resolution logic which fails if the /etc/resolv.conf does not have a
new line at the end. 

If I add a new line to resolv.conf, it is OK again.
@gopherbot
Copy link
Contributor Author

Comment 1 by patrick@sinz.fr:

The function getLineFromData line 22 in the file parse.go
is explicitely checking for a newline, and will not return anything for a line that
is not ended by a newline.
I think that adding:
        if len(data) > 0 {
                s = string(data[0:len(data)]);
                ok=true;
        }
before the for loop should fix the issue, but I lack time to make the tests right now.
func (f *file) getLineFromData() (s string, ok bool) {
        data := f.data
        for i := 0; i < len(data); i++ {
                if data[i] == '\n' {

@rsc
Copy link
Contributor

rsc commented Apr 28, 2010

Comment 2:

Labels changed: added security.

Status changed to Started.

@rsc
Copy link
Contributor

rsc commented Apr 29, 2010

Comment 3:

This issue was closed by revision 7c77e45.

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

2 participants