bin/80732
Maxim Konovalov
maxim at macomnet.ru
Mon May 9 16:10:11 GMT 2005
The following reply was made to PR bin/80732; it has been noted by GNATS.
From: Maxim Konovalov <maxim at macomnet.ru>
To: bug-followup at freebsd.org
Cc:
Subject: bin/80732
Date: Mon, 9 May 2005 20:07:45 +0400 (MSD)
Added to the audit trail.
diff -ur telnetd.orig/ext.h /usr/src/contrib/telnet/telnetd/ext.h
--- telnetd.orig/ext.h Mon May 9 16:41:45 2005
+++ /usr/src/contrib/telnet/telnetd/ext.h Mon May 9 17:01:30 2005
@@ -112,8 +112,7 @@
#endif
process_slc(unsigned char, unsigned char, cc_t),
ptyflush(void),
- putchr(int),
- putf(char *, char *),
+ putf(char *, char *, size_t),
recv_ayt(void),
send_do(int, int),
send_dont(int, int),
diff -ur telnetd.orig/telnetd.c /usr/src/contrib/telnet/telnetd/telnetd.c
--- telnetd.orig/telnetd.c Mon May 9 16:42:13 2005
+++ /usr/src/contrib/telnet/telnetd/telnetd.c Mon May 9 17:01:45 2005
@@ -42,7 +42,6 @@
#include "telnetd.h"
#include "pathnames.h"
-#include <sys/mman.h>
#include <err.h>
#include <libutil.h>
#include <paths.h>
@@ -740,6 +739,7 @@
char *HE;
char *HN;
char *IM;
+ char *IF;
int nfd;
/*
@@ -900,22 +900,40 @@
*/
if (getent(defent, "default") == 1) {
- char *cp=defstrs;
+ char *cp = defstrs;
HE = Getstr("he", &cp);
HN = Getstr("hn", &cp);
- IM = Getstr("im", &cp);
- if (HN && *HN)
+ IF = Getstr("if", &cp);
+ if (HN != NULL && *HN != 0)
(void) strlcpy(host_name, HN, sizeof(host_name));
- if (IM == 0)
- IM = strdup("");
+ if (IF != NULL) {
+ int if_fd;
+
+ if ((if_fd = open(IF, O_RDONLY)) != -1) {
+ struct stat if_fst;
+
+ fstat(if_fd, &if_fst);
+ IM = malloc(if_fst.st_size + 1);
+ read(if_fd, IM, if_fst.st_size);
+ IM[if_fst.st_size] = 0;
+ close(if_fd);
+ } else {
+ IF = NULL;
+ }
+ }
+ if (IF == NULL) {
+ IM = Getstr("im", &cp);
+ if (IM == NULL)
+ IM = strdup("");
+ }
} else {
IM = strdup(DEFAULT_IM);
- HE = 0;
+ HE = NULL;
}
edithost(HE, host_name);
if (hostinfo && *IM)
- putf(IM, ptyibuf2);
+ putf(IM, ptyibuf2, BUFSIZ);
if (pcc)
(void) strncat(ptyibuf2, ptyip, pcc+1);
diff -ur telnetd.orig/utility.c /usr/src/contrib/telnet/telnetd/utility.c
--- telnetd.orig/utility.c Mon May 9 16:42:22 2005
+++ /usr/src/contrib/telnet/telnetd/utility.c Mon May 9 17:01:38 2005
@@ -66,11 +66,9 @@
* also flush the pty input buffer (by dropping its data) if it becomes
* too full.
*/
-
- void
-ttloop()
+void
+ttloop(void)
{
-
DIAG(TD_REPORT, output_data("td: ttloop\r\n"));
if (nfrontp - nbackp > 0) {
netflush();
@@ -393,22 +391,6 @@
editedhost[sizeof editedhost - 1] = '\0';
}
-static char *putlocation;
-
-static void
-putstr(const char *s)
-{
-
- while (*s)
- putchr(*s++);
-}
-
-void
-putchr(int cc)
-{
- *putlocation++ = cc;
-}
-
#ifdef __FreeBSD__
static char fmtstr[] = { "%+" };
#else
@@ -416,11 +398,12 @@
#endif
void
-putf(char *cp, char *where)
+putf(char *cp, char *where, size_t where_size)
{
char *slash;
time_t t;
char db[100];
+ char ch_str[2] = {0, 0};
#ifdef __FreeBSD__
static struct utsname kerninfo;
@@ -428,19 +411,13 @@
uname(&kerninfo);
#endif
- putlocation = where;
-
- while (*cp) {
- if (*cp =='\n') {
- putstr("\r\n");
- cp++;
- continue;
+ while (*cp != 0) {
+ if (*cp == '\n') {
+ strlcat(where, "\r\n", where_size);
} else if (*cp != '%') {
- putchr(*cp++);
- continue;
- }
- switch (*++cp) {
-
+ *ch_str = *cp;
+ strlcat(where, ch_str, where_size);
+ } else switch (*++cp) {
case 't':
#ifdef STREAMSPTY
/* names are like /dev/pts/2 -- we want pts/2 */
@@ -448,46 +425,42 @@
#else
slash = strrchr(line, '/');
#endif
- if (slash == (char *) 0)
- putstr(line);
+ if (slash == NULL)
+ strlcat(where, line, where_size);
else
- putstr(&slash[1]);
+ strlcat(where, &slash[1], where_size);
break;
-
case 'h':
- putstr(editedhost);
+ strlcat(where, editedhost, where_size);
break;
-
case 'd':
#ifdef __FreeBSD__
setlocale(LC_TIME, "");
#endif
(void)time(&t);
(void)strftime(db, sizeof(db), fmtstr, localtime(&t));
- putstr(db);
+ strlcat(where, db, where_size);
break;
-
#ifdef __FreeBSD__
case 's':
- putstr(kerninfo.sysname);
+ strlcat(where, kerninfo.sysname, where_size);
break;
-
case 'm':
- putstr(kerninfo.machine);
+ strlcat(where, kerninfo.machine, where_size);
break;
-
case 'r':
- putstr(kerninfo.release);
+ strlcat(where, kerninfo.release, where_size);
break;
-
case 'v':
- putstr(kerninfo.version);
+ strlcat(where, kerninfo.version, where_size);
break;
#endif
-
case '%':
- putchr('%');
+ *ch_str = '%';
+ strlcat(where, ch_str, where_size);
break;
+ case 0:
+ return;
}
cp++;
}
More information about the freebsd-bugs
mailing list