From owner-freebsd-bugs@FreeBSD.ORG Thu Mar 16 15:10:13 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4178616A4A1 for ; Thu, 16 Mar 2006 15:10:13 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5583643D91 for ; Thu, 16 Mar 2006 15:09:44 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k2GF9b6A082268 for ; Thu, 16 Mar 2006 15:09:37 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k2GF9bRt082267; Thu, 16 Mar 2006 15:09:37 GMT (envelope-from gnats) Resent-Date: Thu, 16 Mar 2006 15:09:37 GMT Resent-Message-Id: <200603161509.k2GF9bRt082267@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Volker Stolz Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 596F316A400 for ; Thu, 16 Mar 2006 09:58:10 +0000 (UTC) (envelope-from stolz@i2.informatik.rwth-aachen.de) Received: from atlas.informatik.rwth-aachen.de (atlas.informatik.RWTH-Aachen.DE [137.226.194.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id BCC3543D46 for ; Thu, 16 Mar 2006 09:58:08 +0000 (GMT) (envelope-from stolz@i2.informatik.rwth-aachen.de) Received: from i2.informatik.rwth-aachen.de (menelaos.informatik.RWTH-Aachen.DE [137.226.194.73]) by atlas.informatik.rwth-aachen.de (8.12.10/8.12.10/SuSE Linux 0.7) with ESMTP id k2G9w7sY032286 for ; Thu, 16 Mar 2006 10:58:07 +0100 Received: (from stolz@localhost) by i2.informatik.rwth-aachen.de (8.13.4/8.13.4/Submit) id k2G9wDY1023810; Thu, 16 Mar 2006 10:58:13 +0100 (CET) (envelope-from stolz) Message-Id: <200603160958.k2G9wDY1023810@i2.informatik.rwth-aachen.de> Date: Thu, 16 Mar 2006 10:58:13 +0100 (CET) From: Volker Stolz To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/94546: [PATCH] Make telnet accept 'host:port' on command line X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Mar 2006 15:10:13 -0000 >Number: 94546 >Category: bin >Synopsis: [PATCH] Make telnet accept 'host:port' on command line >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Mar 16 15:09:37 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Volker Stolz >Release: FreeBSD 6.1-BETA3 i386 >Organization: Lehrstuhl für Informatik II; RWTH Aachen (c) Universität >Environment: System: FreeBSD menelaos.informatik.rwth-aachen.de 6.1-BETA3 FreeBSD 6.1-BETA3 #1: Mon Mar 13 10:45:03 CET 2006 root@menelaos.informatik.rwth-aachen.de:/usr/obj/usr/src/sys/MENELAOS i386 >Description: Almost every network application allows you to specify the remote end through 'host:port', only telnet seems to be stuck in the last millenium. This patch addresses this problem: - permit 'telnet host:port' - fail on 'telnet host:port1 port2' with an error message - protect against IPv6 addresses (they have multiple colons) >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: >Unformatted: