telnet always tries 255.255.255.255

Andrei A. Voropaev av at simcon-mt.com
Thu Jan 27 04:43:19 PST 2005


On Mon, Jan 24, 2005 at 12:03:30PM +0100, Andrei A. Voropaev wrote:
> This is kind of weird and I'm not sure if anyone can help with it :) But
> anyway a try. In my new LFS-6.0 system (AMD-64), whenever I try to do
> telnet it says that it tries to connect to 255.255.255.255 and then, of
> course, unable to connect. This is weird, because ssh and other
> networking programs don't have any problem. What could possibly be wrong
> with telnet?

I've figured this out myself. There's bug in inetutils-1.4.2. There they
use inet_addr function (which is marked as obsolete) and compare return
from this function with (unsigned long)-1. Which works perfectly on 32
bit systems and fails miserably on 64-bit systems. Here's the patch, if
anyone is interested.

--- inetutils-1.4.2/telnet/commands.c	2002-06-26 05:15:06.000000000 +0200
+++ inetutils-1.4.2-patched/telnet/commands.c	2005-01-27 13:23:52.773505864 +0100
@@ -2291,9 +2291,7 @@
 	}
     } else {
 #endif
-	temp = inet_addr(hostp);
-	if (temp != (unsigned long) -1) {
-	    sin.sin_addr.s_addr = temp;
+	if(inet_aton(hostp, &sin.sin_addr) != 0) {
 	    sin.sin_family = AF_INET;
 
 	    if (_hostname)
@@ -2897,8 +2895,7 @@
 		if (!c)
 			cp2 = 0;
 
-		if ((tmp = inet_addr(cp)) != -1) {
-			sin_addr.s_addr = tmp;
+		if (inet_aton(cp, &sin_addr.s_addr) != 0) {
 		} else if (host = gethostbyname(cp)) {
 #if	defined(h_addr)
 			memmove((caddr_t)&sin_addr,

-- 
Minds, like parachutes, function best when open



More information about the lfs-support mailing list