diff --git a/headers/compatibility/bsd/arpa/telnet.h b/headers/compatibility/bsd/arpa/telnet.h index 227a080898..017fb39c22 100644 --- a/headers/compatibility/bsd/arpa/telnet.h +++ b/headers/compatibility/bsd/arpa/telnet.h @@ -131,6 +131,7 @@ extern char *telcmds[]; #define TELOPT_KERMIT 47 /* RFC2840 - Kermit */ #define TELOPT_EXOPL 255 /* extended-options-list */ +#define COMPORT_SET_BAUDRATE 1 /* RFC2217 - Com Port Set Baud Rate */ #define NTELOPTS (1+TELOPT_KERMIT) #ifdef TELOPTS diff --git a/src/bin/network/telnet/Jamfile b/src/bin/network/telnet/Jamfile index c1a31fd514..be1d3c4134 100644 --- a/src/bin/network/telnet/Jamfile +++ b/src/bin/network/telnet/Jamfile @@ -6,10 +6,7 @@ UseHeaders [ FDirName $(HAIKU_TOP) src libs libtelnet ] : false ; UseBuildFeatureHeaders ncurses ; -local defines = [ FDefines USE_TERMIO=1 OLD_ENVIRON=1 ENV_HACK=1 ] ; - -SubDirCcFlags $(defines) ; -SubDirC++Flags $(defines) ; +SubDirCcFlags [ FDefines USE_TERMIO=1 OLD_ENVIRON=1 ENV_HACK=1 ] ; local sources = authenc.c diff --git a/src/bin/network/telnet/authenc.c b/src/bin/network/telnet/authenc.c index 8d1ab6348d..593d061d12 100644 --- a/src/bin/network/telnet/authenc.c +++ b/src/bin/network/telnet/authenc.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +33,7 @@ static const char sccsid[] = "@(#)authenc.c 8.1 (Berkeley) 6/6/93"; #endif #endif #include -__FBSDID("$FreeBSD: src/contrib/telnet/telnet/authenc.c,v 1.6 2003/05/04 02:54:48 obrien Exp $"); +__FBSDID("$FreeBSD$"); #ifdef AUTHENTICATION #ifdef ENCRYPTION diff --git a/src/bin/network/telnet/baud.h b/src/bin/network/telnet/baud.h new file mode 100644 index 0000000000..c422535cf8 --- /dev/null +++ b/src/bin/network/telnet/baud.h @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2014 EMC Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/* + * Try to guess whether speeds are "encoded" (4.2BSD) or just numeric (4.4BSD). + */ +#if B4800 != 4800 +#define DECODE_BAUD +#endif + +#ifdef DECODE_BAUD +#ifndef B7200 +#define B7200 B4800 +#endif + +#ifndef B14400 +#define B14400 B9600 +#endif + +#ifndef B19200 +#define B19200 B14400 +#endif + +#ifndef B28800 +#define B28800 B19200 +#endif + +#ifndef B38400 +#define B38400 B28800 +#endif + +#ifndef B57600 +#define B57600 B38400 +#endif + +#ifndef B76800 +#define B76800 B57600 +#endif + +#ifndef B115200 +#define B115200 B76800 +#endif + +#ifndef B115200 +#define B115200 B76800 +#endif +#endif + +#ifndef B230400 +#define B230400 B115200 +#endif + +/* + * A table of available terminal speeds + */ +struct termspeeds termspeeds[] = { + { 0, B0 }, + { 50, B50 }, + { 75, B75 }, + { 110, B110 }, + { 134, B134 }, + { 150, B150 }, + { 200, B200 }, + { 300, B300 }, + { 600, B600 }, + { 1200, B1200 }, + { 1800, B1800 }, + { 2400, B2400 }, + { 4800, B4800 }, +#ifdef B7200 + { 7200, B7200 }, +#endif + { 9600, B9600 }, +#ifdef B14400 + { 14400, B14400 }, +#endif +#ifdef B19200 + { 19200, B19200 }, +#endif +#ifdef B28800 + { 28800, B28800 }, +#endif +#ifdef B38400 + { 38400, B38400 }, +#endif +#ifdef B57600 + { 57600, B57600 }, +#endif +#ifdef B115200 + { 115200, B115200 }, +#endif +#ifdef B230400 + { 230400, B230400 }, +#endif + { -1, 0 } +}; diff --git a/src/bin/network/telnet/commands.c b/src/bin/network/telnet/commands.c index 5be354892d..fd45979417 100644 --- a/src/bin/network/telnet/commands.c +++ b/src/bin/network/telnet/commands.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,17 +33,15 @@ static const char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95"; #endif #endif #include -__FBSDID("$FreeBSD: src/contrib/telnet/telnet/commands.c,v 1.35 2005/02/28 12:46:52 tobez Exp $"); +__FBSDID("$FreeBSD$"); #include -#if (!defined(__BEOS__) && !defined(__HAIKU__)) -# include -#endif -#include #include -#include +#include +#include #include +#include #include #include #include @@ -78,9 +72,9 @@ __FBSDID("$FreeBSD: src/contrib/telnet/telnet/commands.c,v 1.35 2005/02/28 12:46 #include #endif -//#include +#include #include -//#include +#include #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 256 @@ -115,7 +109,7 @@ static int send_tncmd(void (*)(int, int), const char *, char *); static int setmod(int); static int clearmode(int); static int modehelp(void); -static int sourceroute(struct addrinfo *, char *, char **, int *, int *, int *); +static int sourceroute(struct addrinfo *, char *, unsigned char **, int *, int *, int *); typedef struct { const char *name; /* command name */ @@ -863,7 +857,7 @@ toggle(int argc, char *argv[]) */ #ifdef USE_TERMIO -struct termio new_tc; +struct termio new_tc = { 0, 0, 0, 0, {}, 0, 0 }; #endif struct setlist { @@ -899,6 +893,7 @@ static struct setlist Setlist[] = { { "forw1", "alternate end of line character", NULL, termForw1Charp }, { "forw2", "alternate end of line character", NULL, termForw2Charp }, { "ayt", "alternate AYT character", NULL, termAytCharp }, + { "baudrate", "set remote baud rate", DoBaudRate, ComPortBaudRate }, { NULL, NULL, NULL, NULL } }; @@ -943,7 +938,7 @@ setcmd(int argc, char *argv[]) } ct = getset(argv[1]); - if (ct == 0) { + if (ct == 0 || !(ct->name && ct->name[0] != ' ')) { c = GETTOGGLE(argv[1]); if (c == 0) { fprintf(stderr, "'%s': unknown argument ('set ?' for help).\n", @@ -1019,7 +1014,7 @@ unsetcmd(int argc, char *argv[]) while (argc--) { name = *argv++; ct = getset(name); - if (ct == 0) { + if (ct == 0 || !(ct->name && ct->name[0] != ' ')) { c = GETTOGGLE(name); if (c == 0) { fprintf(stderr, "'%s': unknown argument ('unset ?' for help).\n", @@ -1657,10 +1652,10 @@ env_init(void) char hbuf[256+1]; char *cp2 = strchr((char *)ep->value, ':'); - gethostname(hbuf, 256); - hbuf[256] = '\0'; - cp = (char *)malloc(strlen(hbuf) + strlen(cp2) + 1); - sprintf((char *)cp, "%s%s", hbuf, cp2); + gethostname(hbuf, sizeof(hbuf)); + hbuf[sizeof(hbuf)-1] = '\0'; + asprintf(&cp, "%s%s", hbuf, cp2); + assert(cp != NULL); free(ep->value); ep->value = (unsigned char *)cp; } @@ -2096,9 +2091,6 @@ static const char * sockaddr_ntop(struct sockaddr *sa) { void *addr; -#ifndef INET6_ADDRSTRLEN -# define INET6_ADDRSTRLEN 256 -#endif static char addrbuf[INET6_ADDRSTRLEN]; switch (sa->sa_family) { @@ -2176,7 +2168,7 @@ switch_af(struct addrinfo **aip) int tn(int argc, char *argv[]) { - char *srp = 0; + unsigned char *srp = 0; int proto, opt; int srlen; int srcroute = 0, result; @@ -2271,9 +2263,9 @@ tn(int argc, char *argv[]) hostname = hostp; memset(&su, 0, sizeof su); su.sun_family = AF_UNIX; - strlcpy(su.sun_path, hostp, sizeof su.sun_path); + strncpy(su.sun_path, hostp, sizeof su.sun_path); printf("Trying %s...\n", hostp); - net = socket(AF_UNIX, SOCK_STREAM, 0); + net = socket(PF_UNIX, SOCK_STREAM, 0); if ( net < 0) { perror("socket"); goto fail; @@ -2497,8 +2489,7 @@ tn(int argc, char *argv[]) env_export("USER"); } (void) call(status, "status", "notmuch", 0); - if (setjmp(peerdied) == 0) - telnet(user); + telnet(user); (void) NetClose(net); ExitString("Connection closed by foreign host.\n",1); /*NOTREACHED*/ @@ -2703,7 +2694,7 @@ help(int argc, char *argv[]) printf("?Ambiguous help command %s\n", arg); else if (c == (Command *)0) printf("?Invalid help command %s\n", arg); - else + else if (c->help) printf("%s\n", c->help); } return 0; @@ -2850,10 +2841,10 @@ cmdrc(char *m1, char *m2) * setsockopt, as socket protocol family. */ static int -sourceroute(struct addrinfo *ai, char *arg, char **cpp, int *lenp, int *protop, int *optp) +sourceroute(struct addrinfo *ai, char *arg, unsigned char **cpp, int *lenp, int *protop, int *optp) { static char buf[1024 + ALIGNBYTES]; /*XXX*/ - char *cp, *cp2, *lsrp, *ep; + unsigned char *cp, *cp2, *lsrp, *ep; struct sockaddr_in *_sin; #ifdef INET6 struct sockaddr_in6 *sin6; diff --git a/src/bin/network/telnet/defines.h b/src/bin/network/telnet/defines.h index d49cb2d0a0..d1864845d8 100644 --- a/src/bin/network/telnet/defines.h +++ b/src/bin/network/telnet/defines.h @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,7 +27,7 @@ * SUCH DAMAGE. * * @(#)defines.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/contrib/telnet/telnet/defines.h,v 1.2 2001/11/30 21:06:35 markm Exp $ + * $FreeBSD$ */ #define settimer(x) clocks.x = clocks.system++ diff --git a/src/bin/network/telnet/externs.h b/src/bin/network/telnet/externs.h index 519ac732f4..2edf5d559f 100644 --- a/src/bin/network/telnet/externs.h +++ b/src/bin/network/telnet/externs.h @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,7 +27,7 @@ * SUCH DAMAGE. * * @(#)externs.h 8.3 (Berkeley) 5/30/95 - * $FreeBSD: src/contrib/telnet/telnet/externs.h,v 1.10 2003/05/11 18:17:00 markm Exp $ + * $FreeBSD$ */ #ifndef BSD @@ -72,7 +68,7 @@ typedef unsigned char cc_t; #include #if defined(IPSEC) -#include +#include #if defined(IPSEC_POLICY_IPSEC) extern char *ipsec_policy_in; extern char *ipsec_policy_out; @@ -231,9 +227,12 @@ extern unsigned char NetTraceFile[]; /* Name of file where debugging output goes */ extern void SetNetTrace(char *); /* Function to change where debugging goes */ +extern unsigned char + ComPortBaudRate[]; /* Baud rate of the remote end */ +extern void + DoBaudRate(char *); /* Function to set the baud rate of the remote end */ extern jmp_buf - peerdied, toplevel; /* For error conditions. */ extern void @@ -476,6 +475,16 @@ extern cc_t termAytChar; # endif #endif +typedef struct { + int + system, /* what the current time is */ + echotoggle, /* last time user entered echo character */ + modenegotiated, /* last time operating mode negotiated */ + didnetreceive, /* last time we read data from network */ + gotDM; /* when did we last see a data mark */ +} Clocks; + +extern Clocks clocks; /* Ring buffer structures which are shared */ diff --git a/src/bin/network/telnet/fdset.h b/src/bin/network/telnet/fdset.h index 045bb72214..35b3282be0 100644 --- a/src/bin/network/telnet/fdset.h +++ b/src/bin/network/telnet/fdset.h @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * diff --git a/src/bin/network/telnet/general.h b/src/bin/network/telnet/general.h index 4efa951946..602c94469a 100644 --- a/src/bin/network/telnet/general.h +++ b/src/bin/network/telnet/general.h @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * diff --git a/src/bin/network/telnet/main.c b/src/bin/network/telnet/main.c index 628ab50c5c..befb3eecee 100644 --- a/src/bin/network/telnet/main.c +++ b/src/bin/network/telnet/main.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +33,7 @@ static const char sccsid[] = "@(#)main.c 8.3 (Berkeley) 5/30/95"; #endif #endif #include -__FBSDID("$FreeBSD: src/contrib/telnet/telnet/main.c,v 1.20 2005/01/09 10:24:45 maxim Exp $"); +__FBSDID("$FreeBSD$"); #include #include @@ -91,10 +87,10 @@ usage(void) fprintf(stderr, "usage: %s %s%s%s%s\n", prompt, #ifdef AUTHENTICATION - "[-4] [-6] [-8] [-E] [-K] [-L] [-N] [-S tos] [-X atype] [-c] [-d]", - "\n\t[-e char] [-k realm] [-l user] [-f/-F] [-n tracefile] ", + "[-4] [-6] [-8] [-B baudrate] [-E] [-K] [-L] [-N] [-S tos] [-X atype]", + "\n\t[-c] [-d] [-e char] [-k realm] [-l user] [-f/-F] [-n tracefile] ", #else - "[-4] [-6] [-8] [-E] [-L] [-N] [-S tos] [-c] [-d]", + "[-4] [-6] [-8] [-B baudrate] [-E] [-L] [-N] [-S tos] [-c] [-d]", "\n\t[-e char] [-l user] [-n tracefile] ", #endif "[-r] [-s src_addr] [-u] ", @@ -117,17 +113,16 @@ usage(void) int main(int argc, char *argv[]) { - int ch; -#if (!defined(__BEOS__) && !defined(__HAIKU__)) - char *ep; u_long ultmp; -#endif - char *user; + int ch; + char *ep, *user; char *src_addr = NULL; #ifdef FORWARD extern int forward_flags; #endif /* FORWARD */ + setbuf(stdout, NULL); + setbuf(stderr, NULL); tninit(); /* Clear out things */ TerminalSaveState(); @@ -156,11 +151,8 @@ main(int argc, char *argv[]) #else #define IPSECOPT #endif - - crlf = 1; - while ((ch = getopt(argc, argv, - "468EKLNS:X:acde:fFk:l:n:rs:uxy" IPSECOPT)) != -1) + "468B:EKLNS:X:acde:fFk:l:n:rs:uxy" IPSECOPT)) != -1) #undef IPSECOPT { switch(ch) { @@ -175,6 +167,9 @@ main(int argc, char *argv[]) case '8': eight = 3; /* binary output and input */ break; + case 'B': + DoBaudRate(optarg); + break; case 'E': rlogin = escape = _POSIX_VDISABLE; break; @@ -190,18 +185,15 @@ main(int argc, char *argv[]) doaddrlookup = 0; break; case 'S': -#if (defined(__BEOS__) || defined(__HAIKU__)) - fprintf(stderr, "-S option is not supported\n"); -#else -# ifdef HAS_GETTOS +#ifdef HAS_GETTOS if ((tos = parsetos(optarg, "tcp")) < 0) fprintf(stderr, "%s%s%s%s\n", prompt, ": Bad TOS argument '", optarg, "; will try to use default TOS"); -# else -# define MAXTOS 255 +#else +#define MAXTOS 255 ultmp = strtoul(optarg, &ep, 0); if (*ep || ep == optarg || ultmp > MAXTOS) fprintf(stderr, "%s%s%s%s\n", @@ -210,8 +202,7 @@ main(int argc, char *argv[]) "; will try to use default TOS"); else tos = ultmp; -# endif -#endif /* __BEOS__ */ +#endif break; case 'X': #ifdef AUTHENTICATION diff --git a/src/bin/network/telnet/network.c b/src/bin/network/telnet/network.c index e93345fa68..9a62e8a94f 100644 --- a/src/bin/network/telnet/network.c +++ b/src/bin/network/telnet/network.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +33,7 @@ static const char sccsid[] = "@(#)network.c 8.2 (Berkeley) 12/15/93"; #endif #endif #include -__FBSDID("$FreeBSD: src/contrib/telnet/telnet/network.c,v 1.7 2003/05/04 02:54:48 obrien Exp $"); +__FBSDID("$FreeBSD$"); #include #include @@ -158,7 +154,7 @@ netflush(void) perror(hostname); (void)NetClose(net); ring_clear_mark(&netoring); - longjmp(peerdied, -1); + ExitString("Connection closed by foreign host.\n", 1); /*NOTREACHED*/ } n = 0; diff --git a/src/bin/network/telnet/ring.c b/src/bin/network/telnet/ring.c index 0706133886..efae2e18c1 100644 --- a/src/bin/network/telnet/ring.c +++ b/src/bin/network/telnet/ring.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +33,7 @@ static const char sccsid[] = "@(#)ring.c 8.2 (Berkeley) 5/30/95"; #endif #endif #include -__FBSDID("$FreeBSD: src/contrib/telnet/telnet/ring.c,v 1.7 2003/05/04 02:54:48 obrien Exp $"); +__FBSDID("$FreeBSD$"); /* * This defines a structure for a ring buffer. diff --git a/src/bin/network/telnet/ring.h b/src/bin/network/telnet/ring.h index 6b8d11d2c6..305b9e09ce 100644 --- a/src/bin/network/telnet/ring.h +++ b/src/bin/network/telnet/ring.h @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,7 +27,7 @@ * SUCH DAMAGE. * * @(#)ring.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/contrib/telnet/telnet/ring.h,v 1.4 2001/11/30 22:28:07 markm Exp $ + * $FreeBSD$ */ #if defined(P) diff --git a/src/bin/network/telnet/sys_bsd.c b/src/bin/network/telnet/sys_bsd.c index 2974677a38..fd57df7a88 100644 --- a/src/bin/network/telnet/sys_bsd.c +++ b/src/bin/network/telnet/sys_bsd.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +33,7 @@ static const char sccsid[] = "@(#)sys_bsd.c 8.4 (Berkeley) 5/30/95"; #endif #endif #include -__FBSDID("$FreeBSD: src/contrib/telnet/telnet/sys_bsd.c,v 1.12 2003/05/04 02:54:48 obrien Exp $"); +__FBSDID("$FreeBSD$"); /* * The following routines try to encapsulate what is system dependent @@ -60,6 +56,7 @@ __FBSDID("$FreeBSD: src/contrib/telnet/telnet/sys_bsd.c,v 1.12 2003/05/04 02:54: #include "defines.h" #include "externs.h" #include "types.h" +#include "baud.h" int tout, /* Output file descriptor */ @@ -76,7 +73,7 @@ int olmode = 0; # define old_tc ottyb #else /* USE_TERMIO */ -struct termio old_tc; +struct termio old_tc = { 0, 0, 0, 0, {}, 0, 0 }; # ifndef TCSANOW # ifdef TCSETS @@ -682,71 +679,6 @@ TerminalNewMode(int f) } -/* - * Try to guess whether speeds are "encoded" (4.2BSD) or just numeric (4.4BSD). - */ -#if B4800 != 4800 -#define DECODE_BAUD -#endif - -#ifdef DECODE_BAUD -#ifndef B7200 -#define B7200 B4800 -#endif - -#ifndef B14400 -#define B14400 B9600 -#endif - -#ifndef B19200 -# define B19200 B14400 -#endif - -#ifndef B28800 -#define B28800 B19200 -#endif - -#ifndef B38400 -# define B38400 B28800 -#endif - -#ifndef B57600 -#define B57600 B38400 -#endif - -#ifndef B76800 -#define B76800 B57600 -#endif - -#ifndef B115200 -#define B115200 B76800 -#endif - -#ifndef B230400 -#define B230400 B115200 -#endif - - -/* - * This code assumes that the values B0, B50, B75... - * are in ascending order. They do not have to be - * contiguous. - */ -struct termspeeds { - long speed; - long value; -} termspeeds[] = { - { 0, B0 }, { 50, B50 }, { 75, B75 }, - { 110, B110 }, { 134, B134 }, { 150, B150 }, - { 200, B200 }, { 300, B300 }, { 600, B600 }, - { 1200, B1200 }, { 1800, B1800 }, { 2400, B2400 }, - { 4800, B4800 }, { 7200, B7200 }, { 9600, B9600 }, - { 14400, B14400 }, { 19200, B19200 }, { 28800, B28800 }, - { 38400, B38400 }, { 57600, B57600 }, { 115200, B115200 }, - { 230400, B230400 }, { -1, B230400 } -}; -#endif /* DECODE_BAUD */ - void TerminalSpeeds(long *ispeed, long *ospeed) { @@ -808,14 +740,6 @@ NetNonblockingIO(int fd, int onoff) * Various signal handling routines. */ -/* ARGSUSED */ -static SIG_FUNC_RET -deadpeer(int sig __unused) -{ - setcommandmode(); - longjmp(peerdied, -1); -} - /* ARGSUSED */ SIG_FUNC_RET intr(int sig __unused) @@ -884,7 +808,7 @@ sys_telnet_init(void) { (void) signal(SIGINT, intr); (void) signal(SIGQUIT, intr2); - (void) signal(SIGPIPE, deadpeer); + (void) signal(SIGPIPE, SIG_IGN); #ifdef SIGWINCH (void) signal(SIGWINCH, sendwin); #endif diff --git a/src/bin/network/telnet/telnet.c b/src/bin/network/telnet/telnet.c index c62cc4d0a4..a98dad499c 100644 --- a/src/bin/network/telnet/telnet.c +++ b/src/bin/network/telnet/telnet.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +33,7 @@ static const char sccsid[] = "@(#)telnet.c 8.4 (Berkeley) 5/30/95"; #endif #endif #include -__FBSDID("$FreeBSD: src/contrib/telnet/telnet/telnet.c,v 1.16 2005/03/28 14:45:12 nectar Exp $"); +__FBSDID("$FreeBSD$"); #include @@ -52,6 +48,7 @@ __FBSDID("$FreeBSD: src/contrib/telnet/telnet/telnet.c,v 1.16 2005/03/28 14:45:1 #include #include #include +#include #include #include "ring.h" @@ -68,7 +65,7 @@ __FBSDID("$FreeBSD: src/contrib/telnet/telnet/telnet.c,v 1.16 2005/03/28 14:45:1 #include #endif #include - + #define strip(x) ((my_want_state_is_wont(TELOPT_BINARY)) ? ((x)&0x7f) : (x)) static unsigned char subbuffer[SUBBUFSIZE], @@ -146,7 +143,6 @@ unsigned char telopt_environ = TELOPT_NEW_ENVIRON; #endif jmp_buf toplevel; -jmp_buf peerdied; int flushline; int linemode; @@ -163,7 +159,7 @@ static int is_unique(char *, char **, char **); */ Clocks clocks; - + /* * Initialize telnet environment. */ @@ -197,7 +193,7 @@ init_telnet(void) flushline = 1; telrcv_state = TS_DATA; } - + /* * These routines are in charge of sending option negotiations @@ -207,6 +203,42 @@ init_telnet(void) * is in disagreement as to what the current state should be. */ +unsigned char ComPortBaudRate[256]; + +void +DoBaudRate(char *arg) +{ + char *temp, temp2[11]; + int i; + uint32_t baudrate; + + errno = 0; + baudrate = (uint32_t)strtol(arg, &temp, 10); + if (temp[0] != '\0' || (baudrate == 0 && errno != 0)) + ExitString("Invalid baud rate provided.\n", 1); + + for (i = 1; termspeeds[i].speed != -1; i++) + if (baudrate == termspeeds[i].speed) + break; + if (termspeeds[i].speed == -1) + ExitString("Invalid baud rate provided.\n", 1); + + strlcpy(ComPortBaudRate, arg, sizeof(ComPortBaudRate)); + + if (NETROOM() < sizeof(temp2)) { + ExitString("No room in buffer for baud rate.\n", 1); + /* NOTREACHED */ + } + + snprintf(temp2, sizeof(temp2), "%c%c%c%c....%c%c", IAC, SB, TELOPT_COMPORT, + COMPORT_SET_BAUDRATE, IAC, SE); + + baudrate = htonl(baudrate); + memcpy(&temp2[4], &baudrate, sizeof(baudrate)); + ring_supply_data(&netoring, temp2, sizeof(temp2)); + printsub('>', &temp[2], sizeof(temp2) - 2); +} + void send_do(int c, int init) { @@ -749,7 +781,7 @@ suboption(void) name = gettermname(); len = strlen(name) + 4 + 2; if (len < NETROOM()) { - sprintf(temp, "%c%c%c%c%s%c%c", IAC, SB, TELOPT_TTYPE, + snprintf(temp, sizeof(temp), "%c%c%c%c%s%c%c", IAC, SB, TELOPT_TTYPE, TELQUAL_IS, name, IAC, SE); ring_supply_data(&netoring, temp, len); printsub('>', &temp[2], len-2); @@ -771,7 +803,7 @@ suboption(void) TerminalSpeeds(&ispeed, &ospeed); - sprintf((char *)temp, "%c%c%c%c%ld,%ld%c%c", IAC, SB, TELOPT_TSPEED, + snprintf((char *)temp, sizeof(temp), "%c%c%c%c%ld,%ld%c%c", IAC, SB, TELOPT_TSPEED, TELQUAL_IS, ospeed, ispeed, IAC, SE); len = strlen((char *)temp+4) + 4; /* temp[3] is 0 ... */ @@ -1085,7 +1117,7 @@ lm_mode(unsigned char *cmd, int len, int init) setconnmode(0); /* set changed mode */ } - + /* * slc() @@ -1629,7 +1661,7 @@ env_opt_end(int emptyok) } } - + int telrcv(void) @@ -2014,7 +2046,7 @@ telsnd(void) ring_consumed(&ttyiring, count); return returnValue||count; /* Non-zero if we did anything */ } - + /* * Scheduler() * diff --git a/src/bin/network/telnet/terminal.c b/src/bin/network/telnet/terminal.c index c1c88daa74..b42f861c6f 100644 --- a/src/bin/network/telnet/terminal.c +++ b/src/bin/network/telnet/terminal.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +33,7 @@ static const char sccsid[] = "@(#)terminal.c 8.2 (Berkeley) 2/16/95"; #endif #endif #include -__FBSDID("$FreeBSD: src/contrib/telnet/telnet/terminal.c,v 1.7 2003/05/04 02:54:48 obrien Exp $"); +__FBSDID("$FreeBSD$"); #include #include @@ -111,7 +107,8 @@ init_terminal(void) } /* - * Send as much data as possible to the terminal. + * Send as much data as possible to the terminal, else exits if + * it encounters a permanent failure when writing to the tty. * * Return value: * -1: No useful work done, data waiting to go out. @@ -152,8 +149,19 @@ ttyflush(int drop) } ring_consumed(&ttyoring, n); } - if (n < 0) + if (n < 0) { + if (errno == EAGAIN || errno == EINTR) { + return -1; + } else { + ring_consumed(&ttyoring, ring_full_count(&ttyoring)); + setconnmode(0); + setcommandmode(); + NetClose(net); + fprintf(stderr, "Write error on local output.\n"); + exit(1); + } return -1; + } if (n == n0) { if (n0) return -1; diff --git a/src/bin/network/telnet/types.h b/src/bin/network/telnet/types.h index 191d311fd1..fb91643c45 100644 --- a/src/bin/network/telnet/types.h +++ b/src/bin/network/telnet/types.h @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,13 +36,9 @@ typedef struct { extern Modelist modelist[]; -typedef struct { - int - system, /* what the current time is */ - echotoggle, /* last time user entered echo character */ - modenegotiated, /* last time operating mode negotiated */ - didnetreceive, /* last time we read data from network */ - gotDM; /* when did we last see a data mark */ -} Clocks; +struct termspeeds { + int speed; + int value; +}; -extern Clocks clocks; +extern struct termspeeds termspeeds[]; diff --git a/src/bin/network/telnet/utilities.c b/src/bin/network/telnet/utilities.c index d5fa43a9d9..36432e6a32 100644 --- a/src/bin/network/telnet/utilities.c +++ b/src/bin/network/telnet/utilities.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +33,7 @@ static const char sccsid[] = "@(#)utilities.c 8.3 (Berkeley) 5/30/95"; #endif #endif #include -__FBSDID("$FreeBSD: src/contrib/telnet/telnet/utilities.c,v 1.8 2003/05/04 02:54:48 obrien Exp $"); +__FBSDID("$FreeBSD$"); #define TELOPTS #define TELCMDS @@ -629,7 +625,7 @@ printsub(char direction, unsigned char *pointer, int length) } { char tbuf[64]; - sprintf(tbuf, "%s%s%s%s%s", + snprintf(tbuf, sizeof(tbuf), "%s%s%s%s%s", pointer[2]&MODE_EDIT ? "|EDIT" : "", pointer[2]&MODE_TRAPSIG ? "|TRAPSIG" : "", pointer[2]&MODE_SOFT_TAB ? "|SOFT_TAB" : "", @@ -782,7 +778,7 @@ printsub(char direction, unsigned char *pointer, int length) fprintf(NetTrace, "\" VAR " + noquote); } else #endif /* OLD_ENVIRON */ - fprintf(NetTrace, "\" VALUE " + noquote); + fprintf(NetTrace, "%s", "\" VALUE " + noquote); noquote = 2; break; @@ -798,17 +794,17 @@ printsub(char direction, unsigned char *pointer, int length) fprintf(NetTrace, "\" VALUE " + noquote); } else #endif /* OLD_ENVIRON */ - fprintf(NetTrace, "\" VAR " + noquote); + fprintf(NetTrace, "%s", "\" VAR " + noquote); noquote = 2; break; case ENV_ESC: - fprintf(NetTrace, "\" ESC " + noquote); + fprintf(NetTrace, "%s", "\" ESC " + noquote); noquote = 2; break; case ENV_USERVAR: - fprintf(NetTrace, "\" USERVAR " + noquote); + fprintf(NetTrace, "%s", "\" USERVAR " + noquote); noquote = 2; break; diff --git a/src/bin/network/telnetd/Jamfile b/src/bin/network/telnetd/Jamfile index 2faf3facac..89c73a824e 100644 --- a/src/bin/network/telnetd/Jamfile +++ b/src/bin/network/telnetd/Jamfile @@ -4,11 +4,9 @@ UseBuildFeatureHeaders ncurses ; UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ; UseHeaders [ FDirName $(HAIKU_TOP) src libs ] : true ; UseHeaders [ FDirName $(HAIKU_TOP) src libs libtelnet ] : false ; +UseHeaders [ FDirName $(SUBDIR) .. telnet ] : false ; -local defines = [ FDefines USE_TERMIO=1 ] ; - -SubDirCcFlags $(defines) ; -SubDirC++Flags $(defines) ; +SubDirCcFlags [ FDefines USE_TERMIO=1 ] ; local sources = authenc.c diff --git a/src/bin/network/telnetd/authenc.c b/src/bin/network/telnetd/authenc.c index 7c42dd9596..80b9f39fed 100644 --- a/src/bin/network/telnetd/authenc.c +++ b/src/bin/network/telnetd/authenc.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +33,7 @@ static const char sccsid[] = "@(#)authenc.c 8.2 (Berkeley) 5/30/95"; #endif #endif #include -__FBSDID("$FreeBSD: src/contrib/telnet/telnetd/authenc.c,v 1.8 2003/05/04 02:54:49 obrien Exp $"); +__FBSDID("$FreeBSD$"); #ifdef AUTHENTICATION #ifdef ENCRYPTION diff --git a/src/bin/network/telnetd/defs.h b/src/bin/network/telnetd/defs.h index 3b4927fc02..6baf2bf8ea 100644 --- a/src/bin/network/telnetd/defs.h +++ b/src/bin/network/telnetd/defs.h @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,7 +27,7 @@ * SUCH DAMAGE. * * @(#)defs.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/contrib/telnet/telnetd/defs.h,v 1.2 2001/08/29 14:16:15 markm Exp $ + * $FreeBSD$ */ /* @@ -57,7 +53,7 @@ #include #include #include -//#include +#include #include #include #ifndef FILIO_H diff --git a/src/bin/network/telnetd/ext.h b/src/bin/network/telnetd/ext.h index e1c7e3c8da..fb4954ced5 100644 --- a/src/bin/network/telnetd/ext.h +++ b/src/bin/network/telnetd/ext.h @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,56 +27,60 @@ * SUCH DAMAGE. * * @(#)ext.h 8.2 (Berkeley) 12/15/93 - * $FreeBSD: src/contrib/telnet/telnetd/ext.h,v 1.11 2001/11/30 22:28:07 markm Exp $ + * $FreeBSD$ */ +#ifndef EXTERN +#define EXTERN extern +#endif + /* * Telnet server variable declarations */ -extern char options[256]; -extern char do_dont_resp[256]; -extern char will_wont_resp[256]; -extern int linemode; /* linemode on/off */ +EXTERN char options[256]; +EXTERN char do_dont_resp[256]; +EXTERN char will_wont_resp[256]; +EXTERN int linemode; /* linemode on/off */ #ifdef LINEMODE -extern int uselinemode; /* what linemode to use (on/off) */ -extern int editmode; /* edit modes in use */ -extern int useeditmode; /* edit modes to use */ -extern int alwayslinemode; /* command line option */ -extern int lmodetype; /* Client support for linemode */ +EXTERN int uselinemode; /* what linemode to use (on/off) */ +EXTERN int editmode; /* edit modes in use */ +EXTERN int useeditmode; /* edit modes to use */ +EXTERN int alwayslinemode; /* command line option */ +EXTERN int lmodetype; /* Client support for linemode */ #endif /* LINEMODE */ -extern int flowmode; /* current flow control state */ -extern int restartany; /* restart output on any character state */ +EXTERN int flowmode; /* current flow control state */ +EXTERN int restartany; /* restart output on any character state */ #ifdef DIAGNOSTICS -extern int diagnostic; /* telnet diagnostic capabilities */ +EXTERN int diagnostic; /* telnet diagnostic capabilities */ #endif /* DIAGNOSTICS */ #ifdef BFTPDAEMON -extern int bftpd; /* behave as bftp daemon */ +EXTERN int bftpd; /* behave as bftp daemon */ #endif /* BFTPDAEMON */ #ifdef AUTHENTICATION -extern int auth_level; +EXTERN int auth_level; #endif -extern slcfun slctab[NSLC + 1]; /* slc mapping table */ +EXTERN slcfun slctab[NSLC + 1]; /* slc mapping table */ -extern char *terminaltype; +EXTERN char *terminaltype; /* * I/O data buffers, pointers, and counters. */ -extern char ptyobuf[BUFSIZ+NETSLOP], *pfrontp, *pbackp; +EXTERN char ptyobuf[BUFSIZ+NETSLOP], *pfrontp, *pbackp; -extern char netibuf[BUFSIZ], *netip; +EXTERN char netibuf[BUFSIZ], *netip; -extern char netobuf[BUFSIZ], *nfrontp, *nbackp; -extern char *neturg; /* one past last bye of urgent data */ +EXTERN char netobuf[BUFSIZ], *nfrontp, *nbackp; +EXTERN char *neturg; /* one past last bye of urgent data */ -extern int pcc, ncc; +EXTERN int pcc, ncc; -extern int pty, net; -extern char line[16]; -extern int SYNCHing; /* we are in TELNET SYNCH mode */ +EXTERN int pty, net; +EXTERN char line[32]; +EXTERN int SYNCHing; /* we are in TELNET SYNCH mode */ -extern void +EXTERN void _termstat(void), add_slc(char, char, cc_t), check_slc(void), @@ -137,7 +137,7 @@ extern void tty_binaryin(int), tty_binaryout(int); -extern int +EXTERN int end_slc(unsigned char **), getnpty(void), #ifndef convex @@ -162,7 +162,7 @@ extern int tty_istrapsig(void), tty_linemode(void); -extern void +EXTERN void tty_rspeed(int), tty_setecho(int), tty_setedit(int), @@ -181,7 +181,7 @@ void startslave(char *, int, char *); #ifdef ENCRYPTION extern void (*encrypt_output)(unsigned char *, int); extern int (*decrypt_input)(int); -extern char *nclearto; +EXTERN char *nclearto; #endif /* ENCRYPTION */ @@ -190,7 +190,7 @@ extern char *nclearto; * the relationship between various variables. */ -extern struct { +EXTERN struct { int system, /* what the current time is */ echotoggle, /* last time user entered echo character */ diff --git a/src/bin/network/telnetd/global.c b/src/bin/network/telnetd/global.c index eefd1294c7..5a6fd0db78 100644 --- a/src/bin/network/telnetd/global.c +++ b/src/bin/network/telnetd/global.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +33,7 @@ static const char sccsid[] = "@(#)global.c 8.1 (Berkeley) 6/4/93"; #endif /* not lint */ #endif #include -__FBSDID("$FreeBSD: src/contrib/telnet/telnetd/global.c,v 1.6 2003/05/04 02:54:49 obrien Exp $"); +__FBSDID("$FreeBSD$"); /* * Allocate global variables. We do this @@ -48,5 +44,5 @@ __FBSDID("$FreeBSD: src/contrib/telnet/telnetd/global.c,v 1.6 2003/05/04 02:54:4 */ #include "defs.h" -#define extern +#define EXTERN #include "ext.h" diff --git a/src/bin/network/telnetd/pathnames.h b/src/bin/network/telnetd/pathnames.h index d6fd4c56a4..39f21405e2 100644 --- a/src/bin/network/telnetd/pathnames.h +++ b/src/bin/network/telnetd/pathnames.h @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,14 +27,24 @@ * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/contrib/telnet/telnetd/pathnames.h,v 1.3 2001/08/20 12:28:40 markm Exp $ + * $FreeBSD$ */ -#include +#if BSD > 43 + +# include + +# ifndef _PATH_LOGIN +# define _PATH_LOGIN "/usr/bin/login" +# endif + +#else + +# define _PATH_TTY "/dev/tty" +# ifndef _PATH_LOGIN +# define _PATH_LOGIN "/bin/login" +# endif -#define _PATH_TTY "/dev/tty" -#ifndef _PATH_LOGIN -# define _PATH_LOGIN "/bin/login" #endif #ifdef BFTPDAEMON diff --git a/src/bin/network/telnetd/slc.c b/src/bin/network/telnetd/slc.c index a3b6cd6143..cc0bfbe785 100644 --- a/src/bin/network/telnetd/slc.c +++ b/src/bin/network/telnetd/slc.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +33,7 @@ static const char sccsid[] = "@(#)slc.c 8.2 (Berkeley) 5/30/95"; #endif #endif #include -__FBSDID("$FreeBSD: src/contrib/telnet/telnetd/slc.c,v 1.9 2003/05/04 02:54:49 obrien Exp $"); +__FBSDID("$FreeBSD$"); #include "telnetd.h" diff --git a/src/bin/network/telnetd/state.c b/src/bin/network/telnetd/state.c index cb0154eac6..51764fd8e4 100644 --- a/src/bin/network/telnetd/state.c +++ b/src/bin/network/telnetd/state.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +33,7 @@ static const char sccsid[] = "@(#)state.c 8.5 (Berkeley) 5/30/95"; #endif #endif #include -__FBSDID("$FreeBSD: src/contrib/telnet/telnetd/state.c,v 1.14 2003/05/04 02:54:49 obrien Exp $"); +__FBSDID("$FreeBSD$"); #include #include "telnetd.h" @@ -553,8 +549,10 @@ willoption(int option) #ifdef AUTHENTICATION case TELOPT_AUTHENTICATION: - func = auth_request; - changeok++; + if (auth_level >= 0) { + func = auth_request; + changeok++; + } break; #endif @@ -1599,8 +1597,8 @@ output_data(const char *format, ...) va_start(args, format); if ((len = vasprintf(&buf, format, args)) == -1) { - va_end(args); - return -1; + va_end(args); + return -1; } output_datalen(buf, len); va_end(args); diff --git a/src/bin/network/telnetd/sys_term.c b/src/bin/network/telnetd/sys_term.c index 5404e7b092..77946cd8c8 100644 --- a/src/bin/network/telnetd/sys_term.c +++ b/src/bin/network/telnetd/sys_term.c @@ -1,4 +1,4 @@ - /* +/* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,18 +33,17 @@ static const char sccsid[] = "@(#)sys_term.c 8.4+1 (Berkeley) 5/30/95"; #endif #endif #include -__FBSDID("$FreeBSD: src/contrib/telnet/telnetd/sys_term.c,v 1.18 2003/05/04 02:54:49 obrien Exp $"); +__FBSDID("$FreeBSD$"); #include +//#include #include #include -#if (!defined(__BEOS__) && !defined(__HAIKU__)) -# include -# include -#endif #include "telnetd.h" #include "pathnames.h" +#include "types.h" +#include "baud.h" #ifdef AUTHENTICATION #include @@ -57,22 +52,6 @@ __FBSDID("$FreeBSD: src/contrib/telnet/telnetd/sys_term.c,v 1.18 2003/05/04 02:5 int cleanopen(char *); void scrub_env(void); -#if (!defined(__BEOS__) && !defined(__HAIKU__)) - -struct utmp wtmp; - -# ifdef _PATH_WTMP -char wtmpf[] = _PATH_WTMP; -# else -char wtmpf[] = "/var/log/wtmp"; -# endif -# ifdef _PATH_UTMP -char utmpf[] = _PATH_UTMP; -# else -char utmpf[] = "/var/run/utmp"; -# endif -#endif - char *envinit[3]; extern char **environ; @@ -397,49 +376,30 @@ spcset(int func, cc_t *valp, cc_t **valpp) * * Returns the file descriptor of the opened pty. */ -char alpha[] = "0123456789abcdefghijklmnopqrstuv"; - int getpty(int *ptynum __unused) { int p; - const char *cp; - char *p1, *p2; - int i; + const char *pn; -#if (defined(__BEOS__) || defined(__HAIKU__)) - (void) strcpy(line, "/dev/pt/XX"); -#else - (void) strcpy(line, _PATH_DEV); - (void) strcat(line, "ptyXX"); -#endif - p1 = &line[8]; - p2 = &line[9]; + p = posix_openpt(O_RDWR|O_NOCTTY); + if (p < 0) + return (-1); + + if (grantpt(p) == -1) + return (-1); - for (cp = "pqrsPQRS"; *cp; cp++) { - struct stat stb; + if (unlockpt(p) == -1) + return (-1); + + pn = ptsname(p); + if (pn == NULL) + return (-1); + + if (strlcpy(line, pn, sizeof line) >= sizeof line) + return (-1); - *p1 = *cp; - *p2 = '0'; - /* - * This stat() check is just to keep us from - * looping through all 256 combinations if there - * aren't that many ptys available. - */ - if (stat(line, &stb) < 0) - break; - for (i = 0; i < 32; i++) { - *p2 = alpha[i]; - p = open(line, 2); - if (p > 0) { - line[5] = 't'; - chown(line, 0, 0); - chmod(line, 0600); - return(p); - } - } - } - return(-1); + return (p); } #ifdef LINEMODE @@ -779,56 +739,6 @@ tty_iscrnl(void) #endif } -/* - * Try to guess whether speeds are "encoded" (4.2BSD) or just numeric (4.4BSD). - */ -#if B4800 != 4800 -#define DECODE_BAUD -#endif - -#ifdef DECODE_BAUD - -/* - * A table of available terminal speeds - */ -struct termspeeds { - int speed; - int value; -} termspeeds[] = { - { 0, B0 }, { 50, B50 }, { 75, B75 }, - { 110, B110 }, { 134, B134 }, { 150, B150 }, - { 200, B200 }, { 300, B300 }, { 600, B600 }, - { 1200, B1200 }, { 1800, B1800 }, { 2400, B2400 }, - { 4800, B4800 }, -#ifdef B7200 - { 7200, B7200 }, -#endif - { 9600, B9600 }, -#ifdef B14400 - { 14400, B14400 }, -#endif -#ifdef B19200 - { 19200, B19200 }, -#endif -#ifdef B28800 - { 28800, B28800 }, -#endif -#ifdef B38400 - { 38400, B38400 }, -#endif -#ifdef B57600 - { 57600, B57600 }, -#endif -#ifdef B115200 - { 115200, B115200 }, -#endif -#ifdef B230400 - { 230400, B230400 }, -#endif - { -1, 0 } -}; -#endif /* DECODE_BAUD */ - void tty_tspeed(int val) { @@ -1000,40 +910,6 @@ cleanopen(char *li) return(t); } - -#if (defined(__BEOS__) || defined(__HAIKU__)) -/* taken from DragonFly's telnetd */ -int -login_tty(int t) -{ - if (setsid() < 0) { - fatalperror(net, "setsid()"); - } - - /* - * We get our controlling tty assigned as a side-effect - * of opening up a tty device. But on BSD based systems, - * this only happens if our process group is zero. The - * setsid() call above may have set our pgrp, so clear - * it out before opening the tty... - */ - setpgid(0, 0); - close(open(line, O_RDWR)); - - setenv("TTY", line, 1); - - if (t != 0) - (void) dup2(t, 0); - if (t != 1) - (void) dup2(t, 1); - if (t != 2) - (void) dup2(t, 2); - if (t > 2) - close(t); - return(0); -} -#endif /* __BEOS__ */ - /* * startslave(host) * @@ -1098,6 +974,10 @@ void start_login(char *host undef1, int autologin undef1, char *name undef1) { char **argv; + char *user; + + user = getenv("USER"); + user = (user != NULL) ? strdup(user) : NULL; scrub_env(); @@ -1120,11 +1000,11 @@ start_login(char *host undef1, int autologin undef1, char *name undef1) */ if ((auth_level < 0) || (autologin != AUTH_VALID)) # endif +#endif /* AUTHENTICATION */ { argv = addarg(argv, "-h"); argv = addarg(argv, host); } -#endif /* AUTHENTICATION */ #endif #if !defined(NO_LOGIN_P) argv = addarg(argv, "-p"); @@ -1232,9 +1112,9 @@ start_login(char *host undef1, int autologin undef1, char *name undef1) # endif } else #endif - if (getenv("USER")) { + if (user != NULL) { argv = addarg(argv, "--"); - argv = addarg(argv, getenv("USER")); + argv = addarg(argv, user); #if defined(LOGIN_ARGS) && defined(NO_LOGIN_P) { char **cpp; @@ -1242,17 +1122,6 @@ start_login(char *host undef1, int autologin undef1, char *name undef1) argv = addarg(argv, *cpp); } #endif - /* - * Assume that login will set the USER variable - * correctly. For SysV systems, this means that - * USER will no longer be set, just LOGNAME by - * login. (The problem is that if the auto-login - * fails, and the user then specifies a different - * account name, he can get logged in with both - * LOGNAME and USER in his environment, but the - * USER value will be wrong. - */ - unsetenv("USER"); } #ifdef AUTHENTICATION #if defined(NO_LOGIN_F) && defined(LOGIN_R) @@ -1262,6 +1131,9 @@ start_login(char *host undef1, int autologin undef1, char *name undef1) #endif /* AUTHENTICATION */ closelog(); + if (user != NULL) + free(user); + if (altlogin == NULL) { altlogin = _PATH_LOGIN; } @@ -1283,7 +1155,7 @@ addarg(char **argv, const char *val) */ argv = (char **)malloc(sizeof(*argv) * 12); if (argv == NULL) - return(NULL); + fatal(net, "failure allocating argument space"); *argv++ = (char *)10; *argv = (char *)0; } @@ -1294,11 +1166,12 @@ addarg(char **argv, const char *val) *argv = (char *)((long)(*argv) + 10); argv = (char **)realloc(argv, sizeof(*argv)*((long)(*argv) + 2)); if (argv == NULL) - return(NULL); + fatal(net, "failure allocating argument space"); argv++; cpp = &argv[(long)argv[-1] - 10]; } - *cpp++ = strdup(val); + if ((*cpp++ = strdup(val)) == NULL) + fatal(net, "failure allocating argument space"); *cpp = 0; return(argv); } @@ -1329,8 +1202,18 @@ scrub_env(void) char **cpp, **cpp2; const char **p; + char ** new_environ; + size_t count; - for (cpp2 = cpp = environ; *cpp; cpp++) { + /* Allocate space for scrubbed environment. */ + for (count = 1, cpp = environ; *cpp; count++, cpp++) + continue; + if ((new_environ = malloc(count * sizeof(char *))) == NULL) { + environ = NULL; + return; + } + + for (cpp2 = new_environ, cpp = environ; *cpp; cpp++) { int reject_it = 0; for(p = rej; *p; p++) @@ -1344,10 +1227,15 @@ scrub_env(void) for(p = acc; *p; p++) if(strncmp(*cpp, *p, strlen(*p)) == 0) break; - if(*p != NULL) - *cpp2++ = *cpp; + if(*p != NULL) { + if ((*cpp2++ = strdup(*cpp)) == NULL) { + environ = new_environ; + return; + } + } } *cpp2 = NULL; + environ = new_environ; } /* @@ -1360,26 +1248,7 @@ scrub_env(void) void cleanup(int sig __unused) { - char *p; - sigset_t mask; - p = line + sizeof(_PATH_DEV) - 1; - /* - * Block all signals before clearing the utmp entry. We don't want to - * be called again after calling logout() and then not add the wtmp - * entry because of not finding the corresponding entry in utmp. - */ - sigfillset(&mask); - sigprocmask(SIG_SETMASK, &mask, NULL); -#if (!defined(__BEOS__) && !defined(__HAIKU__)) - if (logout(p)) - logwtmp(p, "", ""); - (void)chmod(line, 0666); - (void)chown(line, 0, 0); - *p = 'p'; - (void)chmod(line, 0666); - (void)chown(line, 0, 0); -#endif - (void) shutdown(net, 2); + (void) shutdown(net, SHUT_RDWR); _exit(1); } diff --git a/src/bin/network/telnetd/telnetd.c b/src/bin/network/telnetd/telnetd.c index f724f7f2b6..622abd82e3 100644 --- a/src/bin/network/telnetd/telnetd.c +++ b/src/bin/network/telnetd/telnetd.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,25 +33,21 @@ static const char sccsid[] = "@(#)telnetd.c 8.4 (Berkeley) 5/30/95"; #endif #endif #include -__FBSDID("$FreeBSD: src/contrib/telnet/telnetd/telnetd.c,v 1.28 2005/05/21 15:28:42 ume Exp $"); +__FBSDID("$FreeBSD$"); #include "telnetd.h" #include "pathnames.h" -//#include +#include #include #include #include #include -#if (!defined(__BEOS__) && !defined(__HAIKU__)) -# include -#endif #include #ifdef AUTHENTICATION #include -int auth_level = 0; #endif #ifdef ENCRYPTION #include @@ -133,16 +125,14 @@ char user_name[256]; int main(int argc, char *argv[]) { + u_long ultmp; struct sockaddr_storage from; int on = 1, fromlen; int ch; -#if (!defined(__BEOS__) && !defined(__HAIKU__)) - u_long ultmp; - char *ep; -#endif #if defined(IPPROTO_IP) && defined(IP_TOS) int tos = -1; #endif + char *ep; pfrontp = pbackp = ptyobuf; netip = netibuf; @@ -273,16 +263,13 @@ main(int argc, char *argv[]) break; case 'S': -#if (defined(__BEOS__) || defined(__HAIKU__)) - fprintf(stderr, "-S option is not supported\n"); -#else -# ifdef HAS_GETTOS +#ifdef HAS_GETTOS if ((tos = parsetos(optarg, "tcp")) < 0) warnx("%s%s%s", "bad TOS argument '", optarg, "'; will try to use default TOS"); -# else -# define MAXTOS 255 +#else +#define MAXTOS 255 ultmp = strtoul(optarg, &ep, 0); if (*ep || ep == optarg || ultmp > MAXTOS) warnx("%s%s%s", @@ -290,8 +277,7 @@ main(int argc, char *argv[]) "'; will try to use default TOS"); else tos = ultmp; -# endif -#endif /* !__BEOS__ */ +#endif break; case 'u': @@ -489,11 +475,13 @@ getterminaltype(char *name undef2) /* * Handle the Authentication option before we do anything else. */ - send_do(TELOPT_AUTHENTICATION, 1); - while (his_will_wont_is_changing(TELOPT_AUTHENTICATION)) - ttloop(); - if (his_state_is_will(TELOPT_AUTHENTICATION)) { - retval = auth_wait(name); + if (auth_level >= 0) { + send_do(TELOPT_AUTHENTICATION, 1); + while (his_will_wont_is_changing(TELOPT_AUTHENTICATION)) + ttloop(); + if (his_state_is_will(TELOPT_AUTHENTICATION)) { + retval = auth_wait(name); + } } #endif @@ -670,6 +658,11 @@ doit(struct sockaddr *who) int err_; /* XXX */ int ptynum; + /* + * Initialize the slc mapping table. + */ + get_slc_defaults(); + /* * Find an available pty to use. */ @@ -699,9 +692,6 @@ doit(struct sockaddr *who) Please contact your net administrator"); remote_hostname[sizeof(remote_hostname) - 1] = '\0'; -#if (!defined(__BEOS__) && !defined(__HAIKU__)) - trimdomain(remote_hostname, UT_HOSTSIZE); -#endif if (!isdigit(remote_hostname[0]) && strlen(remote_hostname) > utmp_len) err_ = getnameinfo(who, who->sa_len, remote_hostname, sizeof(remote_hostname), NULL, 0, @@ -750,13 +740,12 @@ telnet(int f, int p, char *host) char *HE; char *HN; char *IM; + char *IF; + char *if_buf; + int if_fd = -1; + struct stat statbuf; int nfd; - /* - * Initialize the slc mapping table. - */ - get_slc_defaults(); - /* * Do some tests where it is desireable to wait for a response. * Rather than doing them slowly, one at a time, do them all @@ -917,8 +906,13 @@ telnet(int f, int p, char *host) HE = Getstr("he", &cp); HN = Getstr("hn", &cp); IM = Getstr("im", &cp); + IF = Getstr("if", &cp); if (HN && *HN) (void) strlcpy(host_name, HN, sizeof(host_name)); + if (IF) { + if_fd = open(IF, O_RDONLY, 000); + IM = 0; + } if (IM == 0) IM = strdup(""); } else { @@ -928,6 +922,17 @@ telnet(int f, int p, char *host) edithost(HE, host_name); if (hostinfo && *IM) putf(IM, ptyibuf2); + if (if_fd != -1) { + if (fstat(if_fd, &statbuf) != -1 && statbuf.st_size > 0) { + if_buf = (char *) mmap (0, statbuf.st_size, + PROT_READ, 0, if_fd, 0); + if (if_buf != MAP_FAILED) { + putf(if_buf, ptyibuf2); + munmap(if_buf, statbuf.st_size); + } + } + close (if_fd); + } if (pcc) (void) strncat(ptyibuf2, ptyip, pcc+1); @@ -1102,7 +1107,7 @@ telnet(int f, int p, char *host) #if (!defined(__BEOS__) && !defined(__HAIKU__)) if (ptyibuf[0] & TIOCPKT_FLUSHWRITE) { netclear(); /* clear buffer back */ -# ifndef NO_URGENT +#ifndef NO_URGENT /* * There are client telnets on some * operating systems get screwed up @@ -1114,7 +1119,7 @@ telnet(int f, int p, char *host) DIAG(TD_OPTIONS, printoption("td: send IAC", DM)); -# endif +#endif } if (his_state_is_will(TELOPT_LFLOW) && (ptyibuf[0] & @@ -1183,7 +1188,7 @@ interrupt(void) ptyflush(); /* half-hearted */ #ifdef TCSIG - (void) ioctl(pty, TCSIG, (char *)SIGINT); + (void) ioctl(pty, TCSIG, SIGINT); #else /* TCSIG */ init_termbuf(); *pfrontp++ = slctab[SLC_IP].sptr ? @@ -1201,7 +1206,7 @@ sendbrk(void) { ptyflush(); /* half-hearted */ #ifdef TCSIG - (void) ioctl(pty, TCSIG, (char *)SIGQUIT); + (void) ioctl(pty, TCSIG, SIGQUIT); #else /* TCSIG */ init_termbuf(); *pfrontp++ = slctab[SLC_ABORT].sptr ? @@ -1215,7 +1220,7 @@ sendsusp(void) #ifdef SIGTSTP ptyflush(); /* half-hearted */ # ifdef TCSIG - (void) ioctl(pty, TCSIG, (char *)SIGTSTP); + (void) ioctl(pty, TCSIG, SIGTSTP); # else /* TCSIG */ *pfrontp++ = slctab[SLC_SUSP].sptr ? (unsigned char)*slctab[SLC_SUSP].sptr : '\032'; @@ -1232,7 +1237,7 @@ recv_ayt(void) { #if defined(SIGINFO) && defined(TCSIG) if (slctab[SLC_AYT].sptr && *slctab[SLC_AYT].sptr != _POSIX_VDISABLE) { - (void) ioctl(pty, TCSIG, (char *)SIGINFO); + (void) ioctl(pty, TCSIG, SIGINFO); return; } #endif diff --git a/src/bin/network/telnetd/telnetd.h b/src/bin/network/telnetd/telnetd.h index e99a7c93ef..84b55d7164 100644 --- a/src/bin/network/telnetd/telnetd.h +++ b/src/bin/network/telnetd/telnetd.h @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,7 +27,7 @@ * SUCH DAMAGE. * * @(#)telnetd.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/contrib/telnet/telnetd/telnetd.h,v 1.2 2001/11/30 21:06:38 markm Exp $ + * $FreeBSD$ */ diff --git a/src/bin/network/telnetd/termstat.c b/src/bin/network/telnetd/termstat.c index 533eb15545..a17e4fc69b 100644 --- a/src/bin/network/telnetd/termstat.c +++ b/src/bin/network/telnetd/termstat.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +33,7 @@ static const char sccsid[] = "@(#)termstat.c 8.2 (Berkeley) 5/30/95"; #endif #endif #include -__FBSDID("$FreeBSD: src/contrib/telnet/telnetd/termstat.c,v 1.13 2004/07/28 05:37:18 kan Exp $"); +__FBSDID("$FreeBSD$"); #include "telnetd.h" diff --git a/src/bin/network/telnetd/utility.c b/src/bin/network/telnetd/utility.c index b71b03eea7..2e1f61fd5b 100644 --- a/src/bin/network/telnetd/utility.c +++ b/src/bin/network/telnetd/utility.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +33,7 @@ static const char sccsid[] = "@(#)utility.c 8.4 (Berkeley) 5/30/95"; #endif /* not lint */ #endif #include -__FBSDID("$FreeBSD: src/contrib/telnet/telnetd/utility.c,v 1.13 2003/05/04 02:54:49 obrien Exp $"); +__FBSDID("$FreeBSD$"); #ifdef __FreeBSD__ #include @@ -151,31 +147,38 @@ ptyflush(void) * character. */ static char * -nextitem(char *current) +nextitem(char *current, const char *endp) { + if (current >= endp) { + return NULL; + } if ((*current&0xff) != IAC) { return current+1; } + if (current+1 >= endp) { + return NULL; + } switch (*(current+1)&0xff) { case DO: case DONT: case WILL: case WONT: - return current+3; + return current+3 <= endp ? current+3 : NULL; case SB: /* loop forever looking for the SE */ { char *look = current+2; - for (;;) { + while (look < endp) { if ((*look++&0xff) == IAC) { - if ((*look++&0xff) == SE) { + if (look < endp && (*look++&0xff) == SE) { return look; } } } + return NULL; } default: - return current+2; + return current+2 <= endp ? current+2 : NULL; } } /* end of nextitem */ @@ -201,7 +204,7 @@ netclear(void) char *thisitem, *next; char *good; #define wewant(p) ((nfrontp > p) && ((*p&0xff) == IAC) && \ - ((*(p+1)&0xff) != EC) && ((*(p+1)&0xff) != EL)) + (nfrontp > p+1) && ((*(p+1)&0xff) != EC) && ((*(p+1)&0xff) != EL)) #ifdef ENCRYPTION thisitem = nclearto > netobuf ? nclearto : netobuf; @@ -209,7 +212,7 @@ netclear(void) thisitem = netobuf; #endif /* ENCRYPTION */ - while ((next = nextitem(thisitem)) <= nbackp) { + while ((next = nextitem(thisitem, nbackp)) != NULL && (next <= nbackp)) { thisitem = next; } @@ -221,20 +224,23 @@ netclear(void) good = netobuf; /* where the good bytes go */ #endif /* ENCRYPTION */ - while (nfrontp > thisitem) { + while ((thisitem != NULL) && (nfrontp > thisitem)) { if (wewant(thisitem)) { int length; next = thisitem; do { - next = nextitem(next); - } while (wewant(next)); + next = nextitem(next, nfrontp); + } while ((next != NULL) && wewant(next) && (nfrontp > next)); + if (next == NULL) { + next = nfrontp; + } length = next-thisitem; memmove(good, thisitem, length); good += length; thisitem = next; } else { - thisitem = nextitem(thisitem); + thisitem = nextitem(thisitem, nfrontp); } } @@ -360,30 +366,30 @@ edithost(char *pat, char *host) { char *res = editedhost; - if (!pat) - pat = strdup(""); - while (*pat) { - switch (*pat) { + if (pat) { + while (*pat) { + switch (*pat) { - case '#': - if (*host) - host++; - break; + case '#': + if (*host) + host++; + break; - case '@': - if (*host) - *res++ = *host++; - break; + case '@': + if (*host) + *res++ = *host++; + break; - default: - *res++ = *pat; - break; + default: + *res++ = *pat; + break; + } + if (res == &editedhost[sizeof editedhost - 1]) { + *res = '\0'; + return; + } + pat++; } - if (res == &editedhost[sizeof editedhost - 1]) { - *res = '\0'; - return; - } - pat++; } if (*host) (void) strncpy(res, host, @@ -847,22 +853,22 @@ printsub(char direction, unsigned char *pointer, int length) for (i = 2; i < length; i++ ) { switch (pointer[i]) { case NEW_ENV_VAR: - output_data("\" VAR " + noquote); + output_data("%s", "\" VAR " + noquote); noquote = 2; break; case NEW_ENV_VALUE: - output_data("\" VALUE " + noquote); + output_data("%s", "\" VALUE " + noquote); noquote = 2; break; case ENV_ESC: - output_data("\" ESC " + noquote); + output_data("%s", "\" ESC " + noquote); noquote = 2; break; case ENV_USERVAR: - output_data("\" USERVAR " + noquote); + output_data("%s", "\" USERVAR " + noquote); noquote = 2; break; diff --git a/src/libs/libtelnet/auth-proto.h b/src/libs/libtelnet/auth-proto.h index dace1797f6..e216e06a35 100644 --- a/src/libs/libtelnet/auth-proto.h +++ b/src/libs/libtelnet/auth-proto.h @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,7 +27,7 @@ * SUCH DAMAGE. * * @(#)auth-proto.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/contrib/telnet/libtelnet/auth-proto.h,v 1.7 2001/11/30 22:28:07 markm Exp $ + * $FreeBSD$ */ /* diff --git a/src/libs/libtelnet/auth.c b/src/libs/libtelnet/auth.c index a39588ed5a..3488edd84b 100644 --- a/src/libs/libtelnet/auth.c +++ b/src/libs/libtelnet/auth.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -38,7 +34,7 @@ static const char sccsid[] = "@(#)auth.c 8.3 (Berkeley) 5/30/95"; #endif /* not lint */ #endif #include -__FBSDID("$FreeBSD: src/contrib/telnet/libtelnet/auth.c,v 1.10 2003/05/04 02:54:48 obrien Exp $"); +__FBSDID("$FreeBSD$"); /* diff --git a/src/libs/libtelnet/auth.h b/src/libs/libtelnet/auth.h index edd47083d3..bff6f9fdc4 100644 --- a/src/libs/libtelnet/auth.h +++ b/src/libs/libtelnet/auth.h @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,7 +27,7 @@ * SUCH DAMAGE. * * @(#)auth.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/contrib/telnet/libtelnet/auth.h,v 1.3 2001/11/30 21:06:34 markm Exp $ + * $FreeBSD$ */ /* diff --git a/src/libs/libtelnet/enc-proto.h b/src/libs/libtelnet/enc-proto.h index 3f6626be3e..7463c8d94a 100644 --- a/src/libs/libtelnet/enc-proto.h +++ b/src/libs/libtelnet/enc-proto.h @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,7 +27,7 @@ * SUCH DAMAGE. * * @(#)enc-proto.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/contrib/telnet/libtelnet/enc-proto.h,v 1.7 2001/11/30 22:28:07 markm Exp $ + * $FreeBSD$ */ /* diff --git a/src/libs/libtelnet/enc_des.c b/src/libs/libtelnet/enc_des.c index f727c2e755..2c12ad5e0c 100644 --- a/src/libs/libtelnet/enc_des.c +++ b/src/libs/libtelnet/enc_des.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +33,7 @@ static const char sccsid[] = "@(#)enc_des.c 8.3 (Berkeley) 5/30/95"; #endif /* not lint */ #endif #include -__FBSDID("$FreeBSD: src/contrib/telnet/libtelnet/enc_des.c,v 1.10 2003/05/04 02:54:48 obrien Exp $"); +__FBSDID("$FreeBSD$"); #ifdef ENCRYPTION # ifdef AUTHENTICATION @@ -207,9 +203,9 @@ fb64_start(struct fb *fbp, int dir, int server __unused) /* * Create a random feed and send it over. */ - des_random_key((Block *)fbp->temp_feed); - des_ecb_encrypt((Block *)fbp->temp_feed, (Block *)fbp->temp_feed, - fbp->krbdes_sched, 1); + DES_random_key((Block *)fbp->temp_feed); + DES_ecb_encrypt((Block *)fbp->temp_feed, (Block *)fbp->temp_feed, + &fbp->krbdes_sched, 1); p = fbp->fb_feed + 3; *p++ = ENCRYPT_IS; p++; @@ -393,7 +389,7 @@ fb64_session(Session_Key *key, int server, struct fb *fbp) fb64_stream_key(fbp->krbdes_key, &fbp->streams[DIR_ENCRYPT-1]); fb64_stream_key(fbp->krbdes_key, &fbp->streams[DIR_DECRYPT-1]); - des_key_sched((Block *)fbp->krbdes_key, fbp->krbdes_sched); + DES_key_sched((Block *)fbp->krbdes_key, &fbp->krbdes_sched); /* * Now look to see if krbdes_start() was was waiting for * the key to show up. If so, go ahead an call it now @@ -499,7 +495,7 @@ fb64_stream_iv(Block seed, struct stinfo *stp) memmove((void *)stp->str_iv, (void *)seed, sizeof(Block)); memmove((void *)stp->str_output, (void *)seed, sizeof(Block)); - des_key_sched((Block *)stp->str_ikey, stp->str_sched); + DES_key_sched((Block *)stp->str_ikey, &stp->str_sched); stp->str_index = sizeof(Block); } @@ -508,7 +504,7 @@ void fb64_stream_key(Block key, struct stinfo *stp) { memmove((void *)stp->str_ikey, (void *)key, sizeof(Block)); - des_key_sched((Block *)key, stp->str_sched); + DES_key_sched((Block *)key, &stp->str_sched); memmove((void *)stp->str_output, (void *)stp->str_iv, sizeof(Block)); @@ -547,7 +543,7 @@ cfb64_encrypt(unsigned char *s, int c) while (c-- > 0) { if (idx == sizeof(Block)) { Block b; - des_ecb_encrypt((Block *)stp->str_output, (Block *)b, stp->str_sched, 1); + DES_ecb_encrypt((Block *)stp->str_output, (Block *)b, &stp->str_sched, 1); memmove((void *)stp->str_feed, (void *)b, sizeof(Block)); idx = 0; } @@ -580,7 +576,7 @@ cfb64_decrypt(int data) idx = stp->str_index++; if (idx == sizeof(Block)) { Block b; - des_ecb_encrypt((Block *)stp->str_output, (Block *)b, stp->str_sched, 1); + DES_ecb_encrypt((Block *)stp->str_output, (Block *)b, &stp->str_sched, 1); memmove((void *)stp->str_feed, (void *)b, sizeof(Block)); stp->str_index = 1; /* Next time will be 1 */ idx = 0; /* But now use 0 */ @@ -620,7 +616,7 @@ ofb64_encrypt(unsigned char *s, int c) while (c-- > 0) { if (idx == sizeof(Block)) { Block b; - des_ecb_encrypt((Block *)stp->str_feed, (Block *)b, stp->str_sched, 1); + DES_ecb_encrypt((Block *)stp->str_feed, (Block *)b, &stp->str_sched, 1); memmove((void *)stp->str_feed, (void *)b, sizeof(Block)); idx = 0; } @@ -650,7 +646,7 @@ ofb64_decrypt(int data) idx = stp->str_index++; if (idx == sizeof(Block)) { Block b; - des_ecb_encrypt((Block *)stp->str_feed, (Block *)b, stp->str_sched, 1); + DES_ecb_encrypt((Block *)stp->str_feed, (Block *)b, &stp->str_sched, 1); memmove((void *)stp->str_feed, (void *)b, sizeof(Block)); stp->str_index = 1; /* Next time will be 1 */ idx = 0; /* But now use 0 */ diff --git a/src/libs/libtelnet/encrypt.c b/src/libs/libtelnet/encrypt.c index 7227006ceb..398c732151 100644 --- a/src/libs/libtelnet/encrypt.c +++ b/src/libs/libtelnet/encrypt.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -33,7 +29,7 @@ #include -__FBSDID("$FreeBSD: src/contrib/telnet/libtelnet/encrypt.c,v 1.9 2002/06/26 17:06:14 markm Exp $"); +__FBSDID("$FreeBSD$"); #ifndef lint #if 0 @@ -721,6 +717,9 @@ encrypt_keyid(struct key_info *kp, unsigned char *keyid, int len) int dir = kp->dir; int ret = 0; + if (len > MAXKEYLEN) + len = MAXKEYLEN; + if (!(ep = (*kp->getcrypt)(*kp->modep))) { if (len == 0) return; diff --git a/src/libs/libtelnet/encrypt.h b/src/libs/libtelnet/encrypt.h index afe05eb505..fedaeab067 100644 --- a/src/libs/libtelnet/encrypt.h +++ b/src/libs/libtelnet/encrypt.h @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,7 +27,7 @@ * SUCH DAMAGE. * * @(#)encrypt.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/contrib/telnet/libtelnet/encrypt.h,v 1.6 2001/11/30 21:06:34 markm Exp $ + * $FreeBSD$ */ /* @@ -67,7 +63,7 @@ typedef unsigned char *BlockT; #if 0 typedef struct { Block __; } Schedule[16]; #else -#define Schedule des_key_schedule +#define Schedule DES_key_schedule #endif #define VALIDKEY(key) ( key[0] | key[1] | key[2] | key[3] | \ diff --git a/src/libs/libtelnet/genget.c b/src/libs/libtelnet/genget.c index f740c7a45d..e7b48f6b2a 100644 --- a/src/libs/libtelnet/genget.c +++ b/src/libs/libtelnet/genget.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -33,7 +29,7 @@ #include -__FBSDID("$FreeBSD: src/contrib/telnet/libtelnet/genget.c,v 1.7 2001/11/30 21:06:34 markm Exp $"); +__FBSDID("$FreeBSD$"); #ifndef lint #if 0 diff --git a/src/libs/libtelnet/getent.c b/src/libs/libtelnet/getent.c index 4de2c4683f..9e7fd8cc2d 100644 --- a/src/libs/libtelnet/getent.c +++ b/src/libs/libtelnet/getent.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -33,9 +29,14 @@ #include -__FBSDID("$FreeBSD: src/contrib/telnet/libtelnet/getent.c,v 1.7 2001/11/30 21:06:34 markm Exp $"); +__FBSDID("$FreeBSD$"); + +#ifndef lint +#if 0 +static char sccsid[] = "@(#)getent.c 8.2 (Berkeley) 12/15/93"; +#endif +#endif /* not lint */ -#include #include #include diff --git a/src/libs/libtelnet/kerberos.c b/src/libs/libtelnet/kerberos.c index c941fdeb12..5f00fd4018 100644 --- a/src/libs/libtelnet/kerberos.c +++ b/src/libs/libtelnet/kerberos.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -33,7 +29,7 @@ #include -__FBSDID("$FreeBSD: src/contrib/telnet/libtelnet/kerberos.c,v 1.8 2003/01/29 18:14:28 nectar Exp $"); +__FBSDID("$FreeBSD$"); #ifndef lint static const char sccsid[] = "@(#)kerberos.c 8.3 (Berkeley) 5/30/95"; @@ -91,7 +87,7 @@ static char name[ANAME_SZ]; static AUTH_DAT adat = { 0, "", "", "", 0, {}, 0, 0, 0, { 0, "", 0 } }; #ifdef ENCRYPTION static Block session_key = { 0 }; -static des_key_schedule sched; +static DES_key_schedule sched; static Block challenge = { 0 }; #endif /* ENCRYPTION */ @@ -206,10 +202,10 @@ kerberos4_send(Authenticator *ap) if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) { register int i; - des_key_sched(&cred.session, sched); - des_random_key(&session_key); - des_ecb_encrypt(&session_key, &session_key, sched, 0); - des_ecb_encrypt(&session_key, &challenge, sched, 0); + DES_key_sched(&cred.session, sched); + DES_random_key(&session_key); + DES_ecb_encrypt(&session_key, &session_key, sched, 0); + DES_ecb_encrypt(&session_key, &challenge, sched, 0); /* * Increment the challenge by 1, and encrypt it for * later comparison. @@ -221,7 +217,7 @@ kerberos4_send(Authenticator *ap) if (x < 256) /* if no overflow, all done */ break; } - des_ecb_encrypt(&challenge, &challenge, sched, 1); + DES_ecb_encrypt(&challenge, &challenge, sched, 1); } #endif /* ENCRYPTION */ @@ -298,14 +294,14 @@ kerberos4_is(Authenticator *ap, unsigned char *data, int cnt) break; } - des_key_sched(&session_key, sched); + DES_key_sched(&session_key, sched); memmove((void *)datablock, (void *)data, sizeof(Block)); /* * Take the received encrypted challenge, and encrypt * it again to get a unique session_key for the * ENCRYPT option. */ - des_ecb_encrypt(&datablock, &session_key, sched, 1); + DES_ecb_encrypt(&datablock, &session_key, sched, 1); skey.type = SK_DES; skey.length = 8; skey.data = session_key; @@ -314,7 +310,7 @@ kerberos4_is(Authenticator *ap, unsigned char *data, int cnt) * Now decrypt the received encrypted challenge, * increment by one, re-encrypt it and send it back. */ - des_ecb_encrypt(&datablock, &challenge, sched, 0); + DES_ecb_encrypt(&datablock, &challenge, sched, 0); for (r = 7; r >= 0; r--) { register int t; t = (unsigned int)challenge[r] + 1; @@ -322,7 +318,7 @@ kerberos4_is(Authenticator *ap, unsigned char *data, int cnt) if (t < 256) /* if no overflow, all done */ break; } - des_ecb_encrypt(&challenge, &challenge, sched, 1); + DES_ecb_encrypt(&challenge, &challenge, sched, 1); Data(ap, KRB_RESPONSE, challenge, sizeof(challenge)); #endif /* ENCRYPTION */ break; @@ -364,7 +360,7 @@ kerberos4_reply(Authenticator *ap, unsigned char *data, int cnt) #else /* ENCRYPTION */ Data(ap, KRB_CHALLENGE, session_key, sizeof(session_key)); - des_ecb_encrypt(&session_key, &session_key, sched, 1); + DES_ecb_encrypt(&session_key, &session_key, sched, 1); skey.type = SK_DES; skey.length = 8; skey.data = session_key; diff --git a/src/libs/libtelnet/kerberos5.c b/src/libs/libtelnet/kerberos5.c index 7c6bd7f225..63f515310f 100644 --- a/src/libs/libtelnet/kerberos5.c +++ b/src/libs/libtelnet/kerberos5.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -53,7 +49,7 @@ #include -__FBSDID("$FreeBSD: src/contrib/telnet/libtelnet/kerberos5.c,v 1.7 2003/03/06 13:41:53 nectar Exp $"); +__FBSDID("$FreeBSD$"); #ifdef KRB5 @@ -100,6 +96,16 @@ static krb5_ticket *ticket; static krb5_context context; static krb5_auth_context auth_context; +static void +print_krb5_error(krb5_context context, krb5_error_code code, const char *msg) +{ + const char *error_message; + + error_message = krb5_get_error_message(context, code); + printf(msg, error_message); + krb5_free_error_message(context, error_message); +} + static int Data(Authenticator *ap, int type, const char *d, int c) { @@ -182,8 +188,7 @@ kerberos5_send(const char *name, Authenticator *ap) ret = krb5_cc_default(context, &ccache); if (ret) { if (auth_debug_mode) { - printf("Kerberos V5: could not get default ccache: %s\r\n", - krb5_get_err_text (context, ret)); + print_krb5_error(context, ret, "Kerberos V5: could not get default ccache: %s\r\n"); } return 0; } @@ -197,8 +202,7 @@ kerberos5_send(const char *name, Authenticator *ap) ret = krb5_auth_con_init (context, &auth_context); if (ret) { if (auth_debug_mode) { - printf("Kerberos V5: krb5_auth_con_init failed (%s)\r\n", - krb5_get_err_text(context, ret)); + print_krb5_error(context, ret, "Kerberos V5: krb5_auth_con_init failed (%s)\r\n"); } return(0); } @@ -208,9 +212,8 @@ kerberos5_send(const char *name, Authenticator *ap) &net); if (ret) { if (auth_debug_mode) { - printf ("Kerberos V5:" - " krb5_auth_con_setaddrs_from_fd failed (%s)\r\n", - krb5_get_err_text(context, ret)); + print_krb5_error(context, ret, "Kerberos V5:" + " krb5_auth_con_setaddrs_from_fd failed (%s)\r\n"); } return(0); } @@ -236,18 +239,21 @@ kerberos5_send(const char *name, Authenticator *ap) &service); if(ret) { if (auth_debug_mode) { - printf ("Kerberos V5:" + const char *err_str; + + err_str = krb5_get_error_message(context, ret); + printf("Kerberosr V5:" " krb5_sname_to_principal(%s) failed (%s)\r\n", - RemoteHostName, krb5_get_err_text(context, ret)); + RemoteHostName, err_str); + krb5_free_error_message(context, err_str); } return 0; } ret = krb5_unparse_name_fixed(context, service, sname, sizeof(sname)); if(ret) { if (auth_debug_mode) { - printf ("Kerberos V5:" - " krb5_unparse_name_fixed failed (%s)\r\n", - krb5_get_err_text(context, ret)); + print_krb5_error(context, ret, "Kerberos V5:" + " krb5_unparse_name_fixed failed (%s)\r\n"); } return 0; } @@ -260,8 +266,7 @@ kerberos5_send(const char *name, Authenticator *ap) } if (ret) { if (1 || auth_debug_mode) { - printf("Kerberos V5: mk_req failed (%s)\r\n", - krb5_get_err_text(context, ret)); + print_krb5_error(context, ret, "Kerberos V5: mk_req failed (%s)\r\n"); } return(0); } @@ -319,8 +324,7 @@ kerberos5_is(Authenticator *ap, unsigned char *data, int cnt) Data(ap, KRB_REJECT, "krb5_auth_con_init failed", -1); auth_finished(ap, AUTH_REJECT); if (auth_debug_mode) - printf("Kerberos V5: krb5_auth_con_init failed (%s)\r\n", - krb5_get_err_text(context, ret)); + print_krb5_error(context, ret, "Kerberos V5: krb5_auth_con_init failed (%s)\r\n"); return; } @@ -331,9 +335,8 @@ kerberos5_is(Authenticator *ap, unsigned char *data, int cnt) Data(ap, KRB_REJECT, "krb5_auth_con_setaddrs_from_fd failed", -1); auth_finished(ap, AUTH_REJECT); if (auth_debug_mode) - printf("Kerberos V5: " - "krb5_auth_con_setaddrs_from_fd failed (%s)\r\n", - krb5_get_err_text(context, ret)); + print_krb5_error(context, ret, "Kerberos V5: " + "krb5_auth_con_setaddrs_from_fd failed (%s)\r\n"); return; } @@ -346,9 +349,8 @@ kerberos5_is(Authenticator *ap, unsigned char *data, int cnt) Data(ap, KRB_REJECT, "krb5_sock_to_principal failed", -1); auth_finished(ap, AUTH_REJECT); if (auth_debug_mode) - printf("Kerberos V5: " - "krb5_sock_to_principal failed (%s)\r\n", - krb5_get_err_text(context, ret)); + print_krb5_error(context, ret, "Kerberos V5: " + "krb5_sock_to_principal failed (%s)\r\n"); return; } @@ -363,10 +365,12 @@ kerberos5_is(Authenticator *ap, unsigned char *data, int cnt) krb5_free_principal (context, server); if (ret) { char *errbuf; + const char *err_str; + err_str = krb5_get_error_message(context, ret); asprintf(&errbuf, - "Read req failed: %s", - krb5_get_err_text(context, ret)); + "Read req failed: %s", err_str); + krb5_free_error_message(context, err_str); Data(ap, KRB_REJECT, errbuf, -1); if (auth_debug_mode) printf("%s\r\n", errbuf); @@ -387,8 +391,11 @@ kerberos5_is(Authenticator *ap, unsigned char *data, int cnt) if (ret) { char *errbuf; - asprintf(&errbuf, "Bad checksum: %s", - krb5_get_err_text(context, ret)); + const char *err_str; + + err_str = krb5_get_error_message(context, ret); + asprintf(&errbuf, "Bad checksum: %s", err_str); + krb5_free_error_message(context, err_str); Data(ap, KRB_REJECT, errbuf, -1); if (auth_debug_mode) printf ("%s\r\n", errbuf); @@ -404,9 +411,8 @@ kerberos5_is(Authenticator *ap, unsigned char *data, int cnt) Data(ap, KRB_REJECT, "krb5_auth_con_getremotesubkey failed", -1); auth_finished(ap, AUTH_REJECT); if (auth_debug_mode) - printf("Kerberos V5: " - "krb5_auth_con_getremotesubkey failed (%s)\r\n", - krb5_get_err_text(context, ret)); + print_krb5_error(context, ret, "Kerberos V5: " + "krb5_auth_con_getremotesubkey failed (%s)\r\n"); return; } @@ -419,9 +425,8 @@ kerberos5_is(Authenticator *ap, unsigned char *data, int cnt) Data(ap, KRB_REJECT, "krb5_auth_con_getkey failed", -1); auth_finished(ap, AUTH_REJECT); if (auth_debug_mode) - printf("Kerberos V5: " - "krb5_auth_con_getkey failed (%s)\r\n", - krb5_get_err_text(context, ret)); + print_krb5_error(context, ret, "Kerberos V5: " + "krb5_auth_con_getkey failed (%s)\r\n"); return; } if (key_block == NULL) { @@ -440,9 +445,8 @@ kerberos5_is(Authenticator *ap, unsigned char *data, int cnt) "krb5_mk_rep failed", -1); auth_finished(ap, AUTH_REJECT); if (auth_debug_mode) - printf("Kerberos V5: " - "krb5_mk_rep failed (%s)\r\n", - krb5_get_err_text(context, ret)); + print_krb5_error(context, ret, "Kerberos V5: " + "krb5_mk_rep failed (%s)\r\n"); return; } Data(ap, KRB_RESPONSE, outbuf.data, outbuf.length); @@ -509,8 +513,7 @@ kerberos5_is(Authenticator *ap, unsigned char *data, int cnt) ret = krb5_cc_resolve (context, ccname, &ccache); if (ret) { if (auth_debug_mode) - printf ("Kerberos V5: could not get ccache: %s\r\n", - krb5_get_err_text(context, ret)); + print_krb5_error(context, ret, "Kerberos V5: could not get ccache: %s\r\n"); break; } @@ -519,8 +522,7 @@ kerberos5_is(Authenticator *ap, unsigned char *data, int cnt) ticket->client); if (ret) { if (auth_debug_mode) - printf ("Kerberos V5: could not init ccache: %s\r\n", - krb5_get_err_text(context, ret)); + print_krb5_error(context, ret, "Kerberos V5: could not init ccache: %s\r\n"); break; } @@ -533,10 +535,12 @@ kerberos5_is(Authenticator *ap, unsigned char *data, int cnt) &inbuf); if(ret) { char *errbuf; + const char *err_str; + err_str = krb5_get_error_message(context, ret); asprintf (&errbuf, - "Read forwarded creds failed: %s", - krb5_get_err_text (context, ret)); + "Read forwarded creds failed: %s", err_str); + krb5_free_error_message(context, err_str); if(errbuf == NULL) Data(ap, KRB_FORWARD_REJECT, NULL, 0); else @@ -604,8 +608,7 @@ kerberos5_reply(Authenticator *ap, unsigned char *data, int cnt) auth_context, &keyblock); if(ret) { - printf("[ krb5_auth_con_getkey: %s ]\r\n", - krb5_get_err_text(context, ret)); + print_krb5_error(context, ret, "[ krb5_auth_con_getkey: %s ]\r\n"); auth_send_retry(); return; } @@ -632,8 +635,7 @@ kerberos5_reply(Authenticator *ap, unsigned char *data, int cnt) ret = krb5_rd_rep(context, auth_context, &inbuf, &reply); if (ret) { - printf("[ Mutual authentication failed: %s ]\r\n", - krb5_get_err_text (context, ret)); + print_krb5_error(context, ret, "[ Mutual authentication failed: %s ]\r\n"); auth_send_retry(); return; } @@ -748,16 +750,14 @@ kerberos5_forward(Authenticator *ap) ret = krb5_cc_default (context, &ccache); if (ret) { if (auth_debug_mode) - printf ("KerberosV5: could not get default ccache: %s\r\n", - krb5_get_err_text (context, ret)); + print_krb5_error(context, ret, "KerberosV5: could not get default ccache: %s\r\n"); return; } ret = krb5_cc_get_principal (context, ccache, &principal); if (ret) { if (auth_debug_mode) - printf ("KerberosV5: could not get principal: %s\r\n", - krb5_get_err_text (context, ret)); + print_krb5_error(context, ret, "KerberosV5: could not get principal: %s\r\n"); return; } @@ -775,8 +775,7 @@ kerberos5_forward(Authenticator *ap) if (ret) { if (auth_debug_mode) - printf ("KerberosV5: could not get principal: %s\r\n", - krb5_get_err_text (context, ret)); + print_krb5_error(context, ret, "KerberosV5: could not get principal: %s\r\n"); return; } @@ -796,8 +795,7 @@ kerberos5_forward(Authenticator *ap) &out_data); if (ret) { if (auth_debug_mode) - printf ("Kerberos V5: error getting forwarded creds: %s\r\n", - krb5_get_err_text (context, ret)); + print_krb5_error(context, ret, "Kerberos V5: error getting forwarded creds: %s\r\n"); return; } diff --git a/src/libs/libtelnet/key-proto.h b/src/libs/libtelnet/key-proto.h index ba80d42bcf..d8b3a72cc8 100644 --- a/src/libs/libtelnet/key-proto.h +++ b/src/libs/libtelnet/key-proto.h @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -52,7 +48,7 @@ * this software for any purpose. It is provided "as is" without express * or implied warranty. * - * $FreeBSD: src/contrib/telnet/libtelnet/key-proto.h,v 1.2 2001/11/30 21:06:34 markm Exp $ + * $FreeBSD$ */ #ifndef __KEY_PROTO__ diff --git a/src/libs/libtelnet/krb4encpwd.c b/src/libs/libtelnet/krb4encpwd.c index 95ef529c18..e87b5c4127 100644 --- a/src/libs/libtelnet/krb4encpwd.c +++ b/src/libs/libtelnet/krb4encpwd.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -33,7 +29,7 @@ #include -__FBSDID("$FreeBSD: src/contrib/telnet/libtelnet/krb4encpwd.c,v 1.7 2001/11/30 22:28:07 markm Exp $"); +__FBSDID("$FreeBSD$"); #ifndef lint static char sccsid[] = "@(#)krb4encpwd.c 8.3 (Berkeley) 5/30/95"; diff --git a/src/libs/libtelnet/misc-proto.h b/src/libs/libtelnet/misc-proto.h index c3f0a83837..e5559ab691 100644 --- a/src/libs/libtelnet/misc-proto.h +++ b/src/libs/libtelnet/misc-proto.h @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,7 +27,7 @@ * SUCH DAMAGE. * * @(#)misc-proto.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/contrib/telnet/libtelnet/misc-proto.h,v 1.4 2001/11/30 22:28:07 markm Exp $ + * $FreeBSD$ */ /* diff --git a/src/libs/libtelnet/misc.c b/src/libs/libtelnet/misc.c index ac958849ad..ef5de4ee45 100644 --- a/src/libs/libtelnet/misc.c +++ b/src/libs/libtelnet/misc.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -33,7 +29,7 @@ #include -__FBSDID("$FreeBSD: src/contrib/telnet/libtelnet/misc.c,v 1.8 2002/06/26 17:05:08 markm Exp $"); +__FBSDID("$FreeBSD$"); #ifndef lint #if 0 diff --git a/src/libs/libtelnet/misc.h b/src/libs/libtelnet/misc.h index 41ffa7f67a..b0554b0d3f 100644 --- a/src/libs/libtelnet/misc.h +++ b/src/libs/libtelnet/misc.h @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * diff --git a/src/libs/libtelnet/pk.c b/src/libs/libtelnet/pk.c index b7a0773d01..a3d17f396c 100644 --- a/src/libs/libtelnet/pk.c +++ b/src/libs/libtelnet/pk.c @@ -30,7 +30,7 @@ #include -__FBSDID("$FreeBSD: src/contrib/telnet/libtelnet/pk.c,v 1.10 2002/08/22 06:19:07 nsayer Exp $"); +__FBSDID("$FreeBSD$"); /* public key routines */ /* functions: @@ -68,19 +68,19 @@ extractideakey(MINT *ck, IdeaData *ideakey) short base = (1 << 8); char *k; - z = itom(0); - a = itom(0); - madd(ck, z, a); + z = mp_itom(0); + a = mp_itom(0); + mp_madd(ck, z, a); for (i = 0; i < ((KEYSIZE - 128) / 8); i++) { - sdiv(a, base, a, &r); + mp_sdiv(a, base, a, &r); } k = (char *)ideakey; for (i = 0; i < 16; i++) { - sdiv(a, base, a, &r); + mp_sdiv(a, base, a, &r); *k++ = r; } - mfree(z); - mfree(a); + mp_mfree(z); + mp_mfree(a); } /* @@ -97,19 +97,19 @@ extractdeskey(MINT *ck, DesData *deskey) short base = (1 << 8); char *k; - z = itom(0); - a = itom(0); - madd(ck, z, a); + z = mp_itom(0); + a = mp_itom(0); + mp_madd(ck, z, a); for (i = 0; i < ((KEYSIZE - 64) / 2) / 8; i++) { - sdiv(a, base, a, &r); + mp_sdiv(a, base, a, &r); } k = (char *)deskey; for (i = 0; i < 8; i++) { - sdiv(a, base, a, &r); + mp_sdiv(a, base, a, &r); *k++ = r; } - mfree(z); - mfree(a); + mp_mfree(z); + mp_mfree(a); } /* @@ -121,19 +121,19 @@ common_key(char *xsecret, char *xpublic, IdeaData *ideakey, DesData *deskey) MINT *public; MINT *secret; MINT *common; - MINT *modulus = xtom(HEXMODULUS); + MINT *modulus = mp_xtom(HEXMODULUS); - public = xtom(xpublic); - secret = xtom(xsecret); - common = itom(0); - pow(public, secret, modulus, common); + public = mp_xtom(xpublic); + secret = mp_xtom(xsecret); + common = mp_itom(0); + mp_pow(public, secret, modulus, common); extractdeskey(common, deskey); extractideakey(common, ideakey); - des_set_odd_parity(deskey); - mfree(common); - mfree(secret); - mfree(public); - mfree(modulus); + DES_set_odd_parity(deskey); + mp_mfree(common); + mp_mfree(secret); + mp_mfree(public); + mp_mfree(modulus); } /* @@ -142,12 +142,7 @@ common_key(char *xsecret, char *xpublic, IdeaData *ideakey, DesData *deskey) static void getseed(char *seed, int seedsize) { - int i; - - srandomdev(); - for (i = 0; i < seedsize; i++) { - seed[i] = random() & 0xff; - } + arc4random_buf(seed, seedsize); } /* @@ -161,12 +156,12 @@ genkeys(char *public, char *secret) # define BASEBITS (8*sizeof(short) - 1) # define BASE (1 << BASEBITS) - MINT *pk = itom(0); - MINT *sk = itom(0); + MINT *pk = mp_itom(0); + MINT *sk = mp_itom(0); MINT *tmp; - MINT *base = itom(BASE); - MINT *root = itom(PROOT); - MINT *modulus = xtom(HEXMODULUS); + MINT *base = mp_itom((short)BASE); + MINT *root = mp_itom(PROOT); + MINT *modulus = mp_xtom(HEXMODULUS); short r; unsigned short seed[KEYSIZE/BASEBITS + 1]; char *xkey; @@ -174,24 +169,24 @@ genkeys(char *public, char *secret) getseed((char *)seed, sizeof(seed)); for (i = 0; i < KEYSIZE/BASEBITS + 1; i++) { r = seed[i] % BASE; - tmp = itom(r); - mult(sk, base, sk); - madd(sk, tmp, sk); - mfree(tmp); + tmp = mp_itom(r); + mp_mult(sk, base, sk); + mp_madd(sk, tmp, sk); + mp_mfree(tmp); } - tmp = itom(0); - mdiv(sk, modulus, tmp, sk); - mfree(tmp); - pow(root, sk, modulus, pk); - xkey = mtox(sk); + tmp = mp_itom(0); + mp_mdiv(sk, modulus, tmp, sk); + mp_mfree(tmp); + mp_pow(root, sk, modulus, pk); + xkey = mp_mtox(sk); adjust(secret, xkey); - xkey = mtox(pk); + xkey = mp_mtox(pk); adjust(public, xkey); - mfree(sk); - mfree(base); - mfree(pk); - mfree(root); - mfree(modulus); + mp_mfree(sk); + mp_mfree(base); + mp_mfree(pk); + mp_mfree(root); + mp_mfree(modulus); } /* @@ -221,14 +216,14 @@ pk_encode(char *in, char *out, DesData *key) { char buf[256]; DesData i; - des_key_schedule k; + DES_key_schedule k; int l,op,deslen; memset(&i,0,sizeof(i)); memset(buf,0,sizeof(buf)); deslen = ((strlen(in) + 7)/8)*8; - des_key_sched(key, k); - des_cbc_encrypt(in,buf,deslen, k,&i,DES_ENCRYPT); + DES_key_sched(key, &k); + DES_cbc_encrypt(in, buf, deslen, &k, &i, DES_ENCRYPT); for (l=0,op=0;l> 4]; out[op++] = hextab[(buf[l] & 0x0f)]; @@ -242,7 +237,7 @@ pk_decode(char *in, char *out, DesData *key) { char buf[256]; DesData i; - des_key_schedule k; + DES_key_schedule k; int n1,n2,op; size_t l; @@ -259,7 +254,7 @@ pk_decode(char *in, char *out, DesData *key) n2 = in[op+1] - '0'; buf[l] = n1*16 +n2; } - des_key_sched(key, k); - des_cbc_encrypt(buf,out,strlen(in)/2, k,&i,DES_DECRYPT); + DES_key_sched(key, &k); + DES_cbc_encrypt(buf, out, strlen(in) / 2, &k, &i, DES_DECRYPT); out[strlen(in)/2] = '\0'; } diff --git a/src/libs/libtelnet/pk.h b/src/libs/libtelnet/pk.h index 7827c001bc..0c254a80c1 100644 --- a/src/libs/libtelnet/pk.h +++ b/src/libs/libtelnet/pk.h @@ -26,13 +26,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/contrib/telnet/libtelnet/pk.h,v 1.6 2001/11/30 21:06:34 markm Exp $ + * $FreeBSD$ */ /* header for the des routines that we will use */ typedef unsigned char byte, DesData[ 8], IdeaData[16]; -#define DesKeys des_key_schedule +#define DesKeys DES_key_schedule #define DES_DECRYPT 0 #define DES_ENCRYPT 1 diff --git a/src/libs/libtelnet/read_password.c b/src/libs/libtelnet/read_password.c index d479589ae6..0faaa09c57 100644 --- a/src/libs/libtelnet/read_password.c +++ b/src/libs/libtelnet/read_password.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -33,7 +29,7 @@ #include -__FBSDID("$FreeBSD: src/contrib/telnet/libtelnet/read_password.c,v 1.5 2001/11/30 21:06:34 markm Exp $"); +__FBSDID("$FreeBSD$"); #ifndef lint #if 0 diff --git a/src/libs/libtelnet/rsaencpwd.c b/src/libs/libtelnet/rsaencpwd.c index bdf2e37464..9dcf4a658c 100644 --- a/src/libs/libtelnet/rsaencpwd.c +++ b/src/libs/libtelnet/rsaencpwd.c @@ -10,11 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -33,7 +29,11 @@ #include -__FBSDID("$FreeBSD: src/contrib/telnet/libtelnet/rsaencpwd.c,v 1.3 2001/11/30 21:06:34 markm Exp $"); +__FBSDID("$FreeBSD$"); + +#ifndef lint +static char sccsid[] = "@(#)rsaencpwd.c 8.3 (Berkeley) 5/30/95"; +#endif /* not lint */ #ifdef RSA_ENCPWD diff --git a/src/libs/libtelnet/sra.c b/src/libs/libtelnet/sra.c index 8104aaee08..4a759685ca 100644 --- a/src/libs/libtelnet/sra.c +++ b/src/libs/libtelnet/sra.c @@ -30,7 +30,7 @@ #include -__FBSDID("$FreeBSD: src/contrib/telnet/libtelnet/sra.c,v 1.16 2002/05/06 09:48:02 markm Exp $"); +__FBSDID("$FreeBSD$"); #ifdef SRA #ifdef ENCRYPTION @@ -303,7 +303,7 @@ sra_reply(Authenticator *ap, unsigned char *data, int cnt) goto enc_user; } /* encode password */ - memset(pass,0,sizeof(pass)); + memset(pass,0,256); telnet_gets("Password: ",pass,255,0); pk_encode(pass,xpass,&ck); /* send it off */