-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
resolve: reject host names containing spaces #2073
Conversation
Some implementations of getaddrinfo() resolve "127.0.0.1 www.example.com" to "127.0.0.1". Reject such invalid host names. Reported-by: Orange Tsai
no objection, as discussed in the redhat bug that seems to be a valid delim where you could do "foo bar baz" and then x[0], x[4], x[8] without terminating, but I can't think of any reason we would want to allow that in the hostname. i'll watch his presentation this week so i can get more detail |
Shouldn't we rather fail already in |
I will maintain and emphasize that curl still doesn't do a 100% validity check on the URL so the fact that curl considers a URL to be slightly different than other URL parsers when given crap is not surprising. I will also maintain that this is also a direct result of the fact that the URL spec situation right now is mostly anarchy and decay. It is hard to know how to parse "URLs". |
That's related but somewhat separate. Essentially the parser is a little forgiving to be compatible with the wackiness out there, but I can't think of any broken implementation writing a Location like |
I do indeed think we should reject spaces in host names. My comment about not checking 100% correctness was more in regards to the general problem discussed in the presentation by Orange. |
Makes sense, because there are some other URL syntax checks in this function. On the other hand, it's probably easier to let |
Right, a check in url.c:parseurlandfillconn() could check for valid URL letters, and space is not one... |
Is the NetBSD behavior wrong? If so, I will report it as a bug. |
@krytarowski I have no doubts that the libc hackers will have their entirely own and unique perspective on whether this is the correct behavior or not... ask them! |
Host names like "127.0.0.1 moo" would otherwise be accepted by some getaddrinfo() implementations. Fixes #2073
@krytarowski yes, please file a bug report for NetBSD. While you are at it, could you also file a bug report for FreeBSD...? They probably use the same code anyway and could share the bugfix. |
OK, thanks!
No. |
Hmm.. I was trying to find a reproducer in C that behaves differently on NetBSD/FreeBSD/Linux vs OpenBSD. I don't observe a different behavior. Could you please show an example code to show the problem. |
Host names like "127.0.0.1 moo" would otherwise be accepted by some getaddrinfo() implementations. Fixes #2073
Example code: getaddrinfotest.c |
I have an access to a remote OpenBSD host with 6.1.
My desktop:
The result is the same. |
In my tests, OpenBSD has sent a query to the DNS server to resolve My test results (OpenBSD run inside a VMware VM):
|
So, is there a better test-case regardless of DNS server? |
Host names like "127.0.0.1 moo" would otherwise be accepted by some getaddrinfo() implementations. Updated test 1034 and 1035 accordingly. Fixes #2073
I don't know. I don't mind reporting the bug myself with the testcase at hand. |
Someone (TCP/IP stack engineer) suggested me that OpenBSD is wrong and NetBSD is behaving correctly. This behavior depending on DNS is suspicious. |
I have reported the bug in getaddrinfo() to FreeBSD and NetBSD. |
Some implementations of getaddrinfo() resolve
127.0.0.1 www.example.com
to
127.0.0.1
. Reject such invalid host names.There are conference talks by Orange Tsai about this topic. He specifically mentions curl and explains why this is a problem:
Affected getaddrinfo() implementations:
Not affected:
Test program: getaddrinfotest.c