1 diff -up netkit-telnet-0.17/telnetd/ext.h.sa-01-49 netkit-telnet-0.17/telnetd/ext.h
2 --- netkit-telnet-0.17/telnetd/ext.h.sa-01-49 1999-12-12 15:59:44.000000000 +0100
3 +++ netkit-telnet-0.17/telnetd/ext.h 2011-01-20 22:39:54.000000000 +0100
4 @@ -86,7 +86,10 @@ extern char *neturg; /* one past last b
7 /* printf into netobuf */
8 -void netoprintf(const char *fmt, ...) __attribute((format (printf, 1, 2)));
9 +/* void netoprintf(const char *fmt, ...) __attribute((format (printf, 1, 2))); */
10 +#define netoprintf output_data
11 +int output_data(const char *, ...) __attribute((format (printf, 1, 2)));
12 +void output_datalen(const char *, int);
16 @@ -182,7 +185,10 @@ void tty_setsofttab(int);
22 void writenet(unsigned char *, int);
26 extern void (*encrypt_output)(unsigned char *, int);
27 diff -up netkit-telnet-0.17/telnetd/slc.c.sa-01-49 netkit-telnet-0.17/telnetd/slc.c
28 --- netkit-telnet-0.17/telnetd/slc.c.sa-01-49 1999-12-12 15:59:44.000000000 +0100
29 +++ netkit-telnet-0.17/telnetd/slc.c 2011-01-20 22:39:54.000000000 +0100
30 @@ -183,7 +183,7 @@ int end_slc(unsigned char **bufp) {
32 snprintf(slcbuf+slcoff, sizeof(slcbuf)-slcoff, "%c%c", IAC, SE);
34 - writenet(slcbuf, slcoff);
35 + output_datalen(slcbuf, slcoff);
36 netflush(); /* force it out immediately */
39 diff -up netkit-telnet-0.17/telnetd/state.c.sa-01-49 netkit-telnet-0.17/telnetd/state.c
40 --- netkit-telnet-0.17/telnetd/state.c.sa-01-49 1999-12-12 20:41:44.000000000 +0100
41 +++ netkit-telnet-0.17/telnetd/state.c 2011-01-20 22:43:34.000000000 +0100
44 "$Id: state.c,v 1.12 1999/12/12 19:41:44 dholland Exp $";
50 @@ -1365,7 +1366,7 @@ void send_status(void) {
54 - writenet(statusbuf, ncp - statusbuf);
55 + output_datalen(statusbuf, ncp - statusbuf);
56 netflush(); /* Send it on its way */
58 DIAG(TD_OPTIONS, {printsub('>', statusbuf, ncp - statusbuf); netflush();});
59 diff -up netkit-telnet-0.17/telnetd/termstat.c.sa-01-49 netkit-telnet-0.17/telnetd/termstat.c
60 --- netkit-telnet-0.17/telnetd/termstat.c.sa-01-49 1999-12-12 15:59:45.000000000 +0100
61 +++ netkit-telnet-0.17/telnetd/termstat.c 2011-01-20 22:39:54.000000000 +0100
62 @@ -128,7 +128,6 @@ static int _terminit = 0;
67 int need_will_echo = 0;
70 diff -up netkit-telnet-0.17/telnetd/utility.c.sa-01-49 netkit-telnet-0.17/telnetd/utility.c
71 --- netkit-telnet-0.17/telnetd/utility.c.sa-01-49 2011-01-20 22:39:54.000000000 +0100
72 +++ netkit-telnet-0.17/telnetd/utility.c 2011-01-20 22:48:02.000000000 +0100
73 @@ -38,8 +38,10 @@ char util_rcsid[] =
74 "$Id: utility.c,v 1.11 1999/12/12 14:59:45 dholland Exp $";
81 #include <sys/utsname.h>
84 @@ -52,6 +54,53 @@ char util_rcsid[] =
85 * utility functions performing io related tasks
89 + * This function appends data to nfrontp and advances nfrontp.
90 + * Returns the number of characters written altogether (the
91 + * buffer may have been flushed in the process).
95 +output_data(const char *format, ...)
101 + va_start(args, format);
102 + if ((len = vasprintf(&buf, format, args)) == -1)
104 + output_datalen(buf, len);
111 +output_datalen(const char *buf, int len)
113 + int remaining, copied;
115 + remaining = BUFSIZ - (nfrontp - netobuf);
117 + /* Free up enough space if the room is too low*/
118 + if ((len > BUFSIZ ? BUFSIZ : len) > remaining) {
120 + remaining = BUFSIZ - (nfrontp - netobuf);
123 + /* Copy out as much as will fit */
124 + copied = remaining > len ? len : remaining;
125 + memmove(nfrontp, buf, copied);
128 + remaining -= copied;
136 netoprintf(const char *fmt, ...)
138 @@ -67,7 +116,7 @@ netoprintf(const char *fmt, ...)
141 if (len<0 || len==maxsize) {
143 + / * did not fit * /
147 @@ -76,6 +125,7 @@ netoprintf(const char *fmt, ...)
155 @@ -273,10 +323,15 @@ netflush(void)
158 if ((n = nfrontp - nbackp) > 0) {
161 + /* XXX This causes output_data() to recurse and die */
163 { netoprintf("td: netflush %d chars\r\n", n);
164 n = nfrontp - nbackp; /* update count */
169 if (encrypt_output) {
170 char *s = nclearto ? nclearto : nbackp;
171 @@ -310,11 +365,14 @@ netflush(void)
176 - if (errno == EWOULDBLOCK || errno == EINTR)
182 + if (errno == EWOULDBLOCK || errno == EINTR)
190 if (nbackp > nclearto)
191 @@ -332,7 +390,7 @@ netflush(void)
193 } /* end of netflush */
200 @@ -355,7 +413,7 @@ void writenet(register unsigned char *pt
203 } /* end of writenet */
208 * miscellaneous functions doing a variety of little jobs follow ...