From vs@FreeBSD.org  Thu Mar 16 10:29:52 2006
Return-Path: <vs@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 5D89016A423
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 16 Mar 2006 10:29:52 +0000 (UTC)
	(envelope-from vs@FreeBSD.org)
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 4C3A143D6A
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 16 Mar 2006 10:29:48 +0000 (GMT)
	(envelope-from vs@FreeBSD.org)
Received: from freefall.freebsd.org (vs@localhost [127.0.0.1])
	by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k2GATmBi064574
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 16 Mar 2006 10:29:48 GMT
	(envelope-from vs@freefall.freebsd.org)
Received: (from vs@localhost)
	by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k2GATmRx064573;
	Thu, 16 Mar 2006 10:29:48 GMT
	(envelope-from vs)
Message-Id: <200603161029.k2GATmRx064573@freefall.freebsd.org>
Date: Thu, 16 Mar 2006 10:29:48 GMT
From: Volker Stolz <vs@FreeBSD.org>
Reply-To: Volker Stolz <vs@FreeBSD.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] Make telnet accept host:port on the commandline
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         94547
>Category:       bin
>Synopsis:       [PATCH] Make telnet accept host:port on the commandline
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 16 15:09:37 GMT 2006
>Closed-Date:    Thu Mar 16 15:22:29 GMT 2006
>Last-Modified:  Thu Mar 16 15:22:29 GMT 2006
>Originator:     Volker Stolz
>Release:        FreeBSD 6.0-STABLE i386
>Organization:
>Environment:
System: FreeBSD freefall.freebsd.org 6.0-STABLE FreeBSD 6.0-STABLE #0: Sat Dec 10 03:18:20 UTC 2005 kensmith@freefall.freebsd.org:/usr/obj/usr/src/sys/FREEFALL i386


>Description:
Almost every network application allows sepcifying the remote end through
'host:port'. Only telnet seems to be stuck in the last millenium and requires you to
specify both arguments separately, which hinders cut'n'pasting
(sorry, yeah, I do use the mouse occasionaly :).
This patch alleviates this and handles errors gracefully:
- accept 'host:port' on command-line
- handle IPv6 addresses which also may contain colons: only accept the old syntax
- fail gracefully when somebody specified "host:port1 port2" or "host:"
>How-To-Repeat:
>Fix:
--- telnet.patch begins here ---
--- /usr/src/contrib/telnet/telnet/commands.c	Mon Feb 28 13:46:52 2005
+++ src/telnet/telnet/commands.c	Thu Mar 16 10:52:06 2006
@@ -2291,8 +2291,26 @@
 	    hostname++;
 	    srcroute = 1;
 	}
-    } else
-        hostname = hostp;
+    } else {
+      char *colon;
+      /* Did we get host:port? */
+      colon = strrchr(hostp,':');
+      /* Maybe, make sure it's not an IPv6 address */
+      if ((colon != NULL) && (colon == strchr(hostp,':'))) {
+	if (portp) {
+	  fprintf(stderr, "Destination port already set.\n");
+	  goto fail;	  
+	} else { /* Patch \0 into argument */
+	  *colon = '\0';
+	  /* Check if colon was last char in argument: */
+	  colon++;
+	  if ((*colon) != '\0')
+	    portp = colon;
+	}
+      }
+      hostname = hostp;
+      
+    }
     if (!portp) {
       telnetport = 1;
       portp = strdup("telnet");
--- telnet.patch ends here ---
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: vs 
State-Changed-When: Thu Mar 16 15:22:14 UTC 2006 
State-Changed-Why:  
Duplicate because of mailer trouble 

http://www.freebsd.org/cgi/query-pr.cgi?pr=94547 
>Unformatted:
