2011-01-20 21:50:00 +00:00
|
|
|
diff -up netkit-telnet-0.17/telnetd/ext.h.sa-01-49 netkit-telnet-0.17/telnetd/ext.h
|
|
|
|
--- netkit-telnet-0.17/telnetd/ext.h.sa-01-49 1999-12-12 15:59:44.000000000 +0100
|
|
|
|
+++ netkit-telnet-0.17/telnetd/ext.h 2011-01-20 22:39:54.000000000 +0100
|
|
|
|
@@ -86,7 +86,10 @@ extern char *neturg; /* one past last b
|
2004-09-09 13:10:15 +00:00
|
|
|
extern int pcc, ncc;
|
|
|
|
|
|
|
|
/* printf into netobuf */
|
|
|
|
-void netoprintf(const char *fmt, ...) __attribute((format (printf, 1, 2)));
|
|
|
|
+/* void netoprintf(const char *fmt, ...) __attribute((format (printf, 1, 2))); */
|
|
|
|
+#define netoprintf output_data
|
|
|
|
+int output_data(const char *, ...) __attribute((format (printf, 1, 2)));
|
|
|
|
+void output_datalen(const char *, int);
|
|
|
|
|
|
|
|
extern int pty, net;
|
|
|
|
extern char *line;
|
2011-01-20 21:50:00 +00:00
|
|
|
@@ -182,7 +185,10 @@ void tty_setsofttab(int);
|
2004-09-09 13:10:15 +00:00
|
|
|
void tty_tspeed(int);
|
|
|
|
void willoption(int);
|
|
|
|
void wontoption(int);
|
|
|
|
+
|
|
|
|
+#if 0
|
|
|
|
void writenet(unsigned char *, int);
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
#if defined(ENCRYPT)
|
|
|
|
extern void (*encrypt_output)(unsigned char *, int);
|
2011-01-20 21:50:00 +00:00
|
|
|
diff -up netkit-telnet-0.17/telnetd/slc.c.sa-01-49 netkit-telnet-0.17/telnetd/slc.c
|
|
|
|
--- netkit-telnet-0.17/telnetd/slc.c.sa-01-49 1999-12-12 15:59:44.000000000 +0100
|
|
|
|
+++ netkit-telnet-0.17/telnetd/slc.c 2011-01-20 22:39:54.000000000 +0100
|
|
|
|
@@ -183,7 +183,7 @@ int end_slc(unsigned char **bufp) {
|
2004-09-09 13:10:15 +00:00
|
|
|
else {
|
|
|
|
snprintf(slcbuf+slcoff, sizeof(slcbuf)-slcoff, "%c%c", IAC, SE);
|
|
|
|
slcoff += 2;
|
|
|
|
- writenet(slcbuf, slcoff);
|
|
|
|
+ output_datalen(slcbuf, slcoff);
|
|
|
|
netflush(); /* force it out immediately */
|
|
|
|
}
|
|
|
|
}
|
2011-01-20 21:50:00 +00:00
|
|
|
diff -up netkit-telnet-0.17/telnetd/state.c.sa-01-49 netkit-telnet-0.17/telnetd/state.c
|
|
|
|
--- netkit-telnet-0.17/telnetd/state.c.sa-01-49 1999-12-12 20:41:44.000000000 +0100
|
|
|
|
+++ netkit-telnet-0.17/telnetd/state.c 2011-01-20 22:43:34.000000000 +0100
|
2004-09-09 13:10:15 +00:00
|
|
|
@@ -37,6 +37,7 @@
|
|
|
|
char state_rcsid[] =
|
2011-01-20 21:50:00 +00:00
|
|
|
"$Id: state.c,v 1.12 1999/12/12 19:41:44 dholland Exp $";
|
2004-09-09 13:10:15 +00:00
|
|
|
|
|
|
|
+#include <stdarg.h>
|
|
|
|
#include "telnetd.h"
|
|
|
|
|
|
|
|
int not42 = 1;
|
2011-01-20 21:50:00 +00:00
|
|
|
@@ -1365,7 +1366,7 @@ void send_status(void) {
|
2004-09-09 13:10:15 +00:00
|
|
|
ADD(IAC);
|
|
|
|
ADD(SE);
|
|
|
|
|
|
|
|
- writenet(statusbuf, ncp - statusbuf);
|
|
|
|
+ output_datalen(statusbuf, ncp - statusbuf);
|
|
|
|
netflush(); /* Send it on its way */
|
|
|
|
|
|
|
|
DIAG(TD_OPTIONS, {printsub('>', statusbuf, ncp - statusbuf); netflush();});
|
2011-01-20 21:50:00 +00:00
|
|
|
diff -up netkit-telnet-0.17/telnetd/termstat.c.sa-01-49 netkit-telnet-0.17/telnetd/termstat.c
|
|
|
|
--- netkit-telnet-0.17/telnetd/termstat.c.sa-01-49 1999-12-12 15:59:45.000000000 +0100
|
|
|
|
+++ netkit-telnet-0.17/telnetd/termstat.c 2011-01-20 22:39:54.000000000 +0100
|
|
|
|
@@ -128,7 +128,6 @@ static int _terminit = 0;
|
2004-09-09 13:10:15 +00:00
|
|
|
void
|
|
|
|
localstat()
|
|
|
|
{
|
|
|
|
- void netflush();
|
|
|
|
int need_will_echo = 0;
|
|
|
|
|
|
|
|
/*
|
2011-01-20 21:50:00 +00:00
|
|
|
diff -up netkit-telnet-0.17/telnetd/utility.c.sa-01-49 netkit-telnet-0.17/telnetd/utility.c
|
|
|
|
--- netkit-telnet-0.17/telnetd/utility.c.sa-01-49 2011-01-20 22:39:54.000000000 +0100
|
|
|
|
+++ netkit-telnet-0.17/telnetd/utility.c 2011-01-20 22:48:02.000000000 +0100
|
|
|
|
@@ -38,8 +38,10 @@ char util_rcsid[] =
|
|
|
|
"$Id: utility.c,v 1.11 1999/12/12 14:59:45 dholland Exp $";
|
2004-09-09 13:10:15 +00:00
|
|
|
|
|
|
|
#define PRINTOPTIONS
|
|
|
|
+#define _GNU_SOURCE
|
2011-01-20 21:50:00 +00:00
|
|
|
|
2004-09-09 13:10:15 +00:00
|
|
|
#include <stdarg.h>
|
2011-01-20 21:50:00 +00:00
|
|
|
+#include <stdio.h>
|
2004-09-09 13:10:15 +00:00
|
|
|
#include <sys/utsname.h>
|
|
|
|
|
|
|
|
#ifdef AUTHENTICATE
|
2011-01-20 21:50:00 +00:00
|
|
|
@@ -52,6 +54,53 @@ char util_rcsid[] =
|
2004-09-09 13:10:15 +00:00
|
|
|
* utility functions performing io related tasks
|
|
|
|
*/
|
|
|
|
|
|
|
|
+/*
|
|
|
|
+ * This function appends data to nfrontp and advances nfrontp.
|
|
|
|
+ * Returns the number of characters written altogether (the
|
|
|
|
+ * buffer may have been flushed in the process).
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+int
|
|
|
|
+output_data(const char *format, ...)
|
|
|
|
+{
|
|
|
|
+ va_list args;
|
|
|
|
+ int len;
|
|
|
|
+ char *buf;
|
|
|
|
+
|
|
|
|
+ va_start(args, format);
|
|
|
|
+ if ((len = vasprintf(&buf, format, args)) == -1)
|
|
|
|
+ return -1;
|
|
|
|
+ output_datalen(buf, len);
|
|
|
|
+ va_end(args);
|
|
|
|
+ free(buf);
|
|
|
|
+ return (len);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+output_datalen(const char *buf, int len)
|
|
|
|
+{
|
|
|
|
+ int remaining, copied;
|
|
|
|
+
|
|
|
|
+ remaining = BUFSIZ - (nfrontp - netobuf);
|
|
|
|
+ while (len > 0) {
|
|
|
|
+ /* Free up enough space if the room is too low*/
|
|
|
|
+ if ((len > BUFSIZ ? BUFSIZ : len) > remaining) {
|
|
|
|
+ netflush();
|
|
|
|
+ remaining = BUFSIZ - (nfrontp - netobuf);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* Copy out as much as will fit */
|
|
|
|
+ copied = remaining > len ? len : remaining;
|
|
|
|
+ memmove(nfrontp, buf, copied);
|
|
|
|
+ nfrontp += copied;
|
|
|
|
+ len -= copied;
|
|
|
|
+ remaining -= copied;
|
|
|
|
+ buf += copied;
|
|
|
|
+ }
|
|
|
|
+ return;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
void
|
|
|
|
netoprintf(const char *fmt, ...)
|
|
|
|
{
|
2011-01-20 21:50:00 +00:00
|
|
|
@@ -67,7 +116,7 @@ netoprintf(const char *fmt, ...)
|
2004-09-09 13:10:15 +00:00
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
if (len<0 || len==maxsize) {
|
|
|
|
- /* didn't fit */
|
|
|
|
+ / * did not fit * /
|
|
|
|
netflush();
|
|
|
|
}
|
|
|
|
else {
|
2011-01-20 21:50:00 +00:00
|
|
|
@@ -76,6 +125,7 @@ netoprintf(const char *fmt, ...)
|
2004-09-09 13:10:15 +00:00
|
|
|
}
|
|
|
|
nfrontp += len;
|
|
|
|
}
|
|
|
|
+*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ttloop
|
2011-01-20 21:50:00 +00:00
|
|
|
@@ -273,10 +323,15 @@ netflush(void)
|
2004-09-09 13:10:15 +00:00
|
|
|
int n;
|
|
|
|
|
|
|
|
if ((n = nfrontp - nbackp) > 0) {
|
|
|
|
+
|
|
|
|
+#if 0
|
|
|
|
+ /* XXX This causes output_data() to recurse and die */
|
|
|
|
DIAG(TD_REPORT,
|
|
|
|
{ netoprintf("td: netflush %d chars\r\n", n);
|
|
|
|
n = nfrontp - nbackp; /* update count */
|
|
|
|
});
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
#if defined(ENCRYPT)
|
|
|
|
if (encrypt_output) {
|
|
|
|
char *s = nclearto ? nclearto : nbackp;
|
2011-01-20 21:50:00 +00:00
|
|
|
@@ -310,11 +365,14 @@ netflush(void)
|
2004-09-09 13:10:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
- if (n < 0) {
|
|
|
|
- if (errno == EWOULDBLOCK || errno == EINTR)
|
|
|
|
- return;
|
|
|
|
- cleanup(0);
|
|
|
|
- }
|
|
|
|
+
|
|
|
|
+ if (n == -1) {
|
|
|
|
+ if (errno == EWOULDBLOCK || errno == EINTR)
|
|
|
|
+ return;
|
|
|
|
+ cleanup(0);
|
|
|
|
+ /* NOTREACHED */
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
nbackp += n;
|
|
|
|
#if defined(ENCRYPT)
|
|
|
|
if (nbackp > nclearto)
|
2011-01-20 21:50:00 +00:00
|
|
|
@@ -332,7 +390,7 @@ netflush(void)
|
2004-09-09 13:10:15 +00:00
|
|
|
return;
|
|
|
|
} /* end of netflush */
|
|
|
|
|
|
|
|
-
|
|
|
|
+#if 0
|
|
|
|
/*
|
|
|
|
* writenet
|
|
|
|
*
|
2011-01-20 21:50:00 +00:00
|
|
|
@@ -355,7 +413,7 @@ void writenet(register unsigned char *pt
|
2004-09-09 13:10:15 +00:00
|
|
|
nfrontp += len;
|
|
|
|
|
|
|
|
} /* end of writenet */
|
|
|
|
-
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* miscellaneous functions doing a variety of little jobs follow ...
|