Bug 41841 - telnet client can't resolve hostname in -s option
Summary: telnet client can't resolve hostname in -s option
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 4.6-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-08-21 11:30 UTC by Dmitry Pryanishnikov
Modified: 2002-10-02 01:27 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Pryanishnikov 2002-08-21 11:30:01 UTC
	Telnet client can't resolve host name given with -s option:
	"telnet -s host" doesn't work while "telnet -s IP" works.

Fix: 

Don't know.
How-To-Repeat: 	
	dmitry@atlantis$ telnet localhost
	Trying 127.0.0.1...
	telnet: connect to address 127.0.0.1: Connection refused
	telnet: Unable to connect to remote host

	So "localhost" resolves OK...

	dmitry@atlantis$ telnet -s localhost localhost
	localhost: hostname nor servname provided, or not known

	...except in -s option!

	dmitry@atlantis$ telnet -s 127.0.0.1 localhost
	Trying 127.0.0.1...
	telnet: connect to address 127.0.0.1: Connection refused
	telnet: Unable to connect to remote host

	-s IP still works.
Comment 1 Maxim Maximov 2002-08-21 11:54:07 UTC
 From src/usr.bin/telnet/command.c:

     if (src_addr != NULL) {
         memset(&hints, 0, sizeof(hints));
         hints.ai_flags = AI_NUMERICHOST;
         hints.ai_family = family;
         hints.ai_socktype = SOCK_STREAM;
         error = getaddrinfo(src_addr, 0, &hints, &src_res);

note "hints.ai_flags = AI_NUMERICHOST". it states, that "a non-NULL 
nodename string must be a numeric host address string." (excerpt from 
getaddrinfo(3))

so either manpage lies, or one should remove this string from commands.c

Dmitry Pryanishnikov wrote:
>>Number:         41841
>>Category:       bin
>>Synopsis:       telnet client can't resolve hostname in -s option
>>Confidential:   no
>>Severity:       serious
>>Priority:       medium
>>Responsible:    freebsd-bugs
>>State:          open
>>Quarter:        
>>Keywords:       
>>Date-Required:
>>Class:          sw-bug
>>Submitter-Id:   current-users
>>Arrival-Date:   Wed Aug 21 03:30:01 PDT 2002
>>Closed-Date:
>>Last-Modified:
>>Originator:     Dmitry Pryanishnikov
>>Release:        FreeBSD 4.6-RELEASE-p1 i386
>>Organization:
> 
> Atlantis ISP
> 
>>Environment:
>>Description:
> 
> 	Telnet client can't resolve host name given with -s option:
> 	"telnet -s host" doesn't work while "telnet -s IP" works.
> 
>>How-To-Repeat:
> 
> 	
> 	dmitry@atlantis$ telnet localhost
> 	Trying 127.0.0.1...
> 	telnet: connect to address 127.0.0.1: Connection refused
> 	telnet: Unable to connect to remote host
> 
> 	So "localhost" resolves OK...
> 
> 	dmitry@atlantis$ telnet -s localhost localhost
> 	localhost: hostname nor servname provided, or not known
> 
> 	...except in -s option!
> 
> 	dmitry@atlantis$ telnet -s 127.0.0.1 localhost
> 	Trying 127.0.0.1...
> 	telnet: connect to address 127.0.0.1: Connection refused
> 	telnet: Unable to connect to remote host
> 
> 	-s IP still works.
> 
>>Fix:
> 
> 	Don't know.
> 
>>Release-Note:
>>Audit-Trail:
>>Unformatted:
> 
>  >System: FreeBSD atlantis.atlantis.dp.ua 4.6-RELEASE-p1 FreeBSD 4.6-RELEASE-p1 #0: Sat Jul 6 17:31:08 EEST 2002 root@atlantis.dp.ua:/usr/src/sys/compile/ATLANTIS i386
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-bugs" in the body of the message


-- 
Maxim Maximov
System Administrator
AGAVA Software (http://www.agava.com)
Comment 2 Dmitry Pryanishnikov 2002-08-23 10:05:12 UTC
Hello!

Maxim Maximov <mcsi@agava.com> wrote:
> so either manpage lies, or one should remove this string from commands.c

 Yes, the following patch:

--- commands.c.orig     Sat Apr 13 14:07:13 2002
+++ commands.c  Fri Aug 23 08:56:26 2002
@@ -1980,7 +1980,6 @@
     if (src_addr != NULL) {
        memset(&hints, 0, sizeof(hints));
-       hints.ai_flags = AI_NUMERICHOST;
        hints.ai_family = family;
        hints.ai_socktype = SOCK_STREAM;
        error = getaddrinfo(src_addr, 0, &hints, &src_res);

fixes the problem in 4.6.2-RELEASE (commands.c version 1.21.2.5).
Please commit this trivial fix!
Comment 3 dd freebsd_committer freebsd_triage 2002-10-02 01:27:17 UTC
State Changed
From-To: open->closed

Fixed in -current.  I'll MFC after 4.7.