Date: Thu, 16 Mar 2006 10:58:13 +0100 (CET) From: Volker Stolz <vs@FreeBSD.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/94546: [PATCH] Make telnet accept 'host:port' on command line Message-ID: <200603160958.k2G9wDY1023810@i2.informatik.rwth-aachen.de> Resent-Message-ID: <200603161509.k2GF9bRt082267@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200603160958.k2G9wDY1023810>