]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/telnet-0.17-sa-01-49.patch
Merge branch 'ipsec' into next
[ipfire-2.x.git] / src / patches / telnet-0.17-sa-01-49.patch
CommitLineData
b52f6eb2
DW
1diff -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
5 extern int pcc, ncc;
6
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);
13
14 extern int pty, net;
15 extern char *line;
16@@ -182,7 +185,10 @@ void tty_setsofttab(int);
17 void tty_tspeed(int);
18 void willoption(int);
19 void wontoption(int);
20+
21+#if 0
22 void writenet(unsigned char *, int);
23+#endif
24
25 #if defined(ENCRYPT)
26 extern void (*encrypt_output)(unsigned char *, int);
27diff -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) {
31 else {
32 snprintf(slcbuf+slcoff, sizeof(slcbuf)-slcoff, "%c%c", IAC, SE);
33 slcoff += 2;
34- writenet(slcbuf, slcoff);
35+ output_datalen(slcbuf, slcoff);
36 netflush(); /* force it out immediately */
37 }
38 }
39diff -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
42@@ -37,6 +37,7 @@
43 char state_rcsid[] =
44 "$Id: state.c,v 1.12 1999/12/12 19:41:44 dholland Exp $";
45
46+#include <stdarg.h>
47 #include "telnetd.h"
48
49 int not42 = 1;
50@@ -1365,7 +1366,7 @@ void send_status(void) {
51 ADD(IAC);
52 ADD(SE);
53
54- writenet(statusbuf, ncp - statusbuf);
55+ output_datalen(statusbuf, ncp - statusbuf);
56 netflush(); /* Send it on its way */
57
58 DIAG(TD_OPTIONS, {printsub('>', statusbuf, ncp - statusbuf); netflush();});
59diff -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;
63 void
64 localstat()
65 {
66- void netflush();
67 int need_will_echo = 0;
68
69 /*
70diff -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 $";
75
76 #define PRINTOPTIONS
77+#define _GNU_SOURCE
78
79 #include <stdarg.h>
80+#include <stdio.h>
81 #include <sys/utsname.h>
82
83 #ifdef AUTHENTICATE
84@@ -52,6 +54,53 @@ char util_rcsid[] =
85 * utility functions performing io related tasks
86 */
87
88+/*
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).
92+ */
93+
94+int
95+output_data(const char *format, ...)
96+{
97+ va_list args;
98+ int len;
99+ char *buf;
100+
101+ va_start(args, format);
102+ if ((len = vasprintf(&buf, format, args)) == -1)
103+ return -1;
104+ output_datalen(buf, len);
105+ va_end(args);
106+ free(buf);
107+ return (len);
108+}
109+
110+void
111+output_datalen(const char *buf, int len)
112+{
113+ int remaining, copied;
114+
115+ remaining = BUFSIZ - (nfrontp - netobuf);
116+ while (len > 0) {
117+ /* Free up enough space if the room is too low*/
118+ if ((len > BUFSIZ ? BUFSIZ : len) > remaining) {
119+ netflush();
120+ remaining = BUFSIZ - (nfrontp - netobuf);
121+ }
122+
123+ /* Copy out as much as will fit */
124+ copied = remaining > len ? len : remaining;
125+ memmove(nfrontp, buf, copied);
126+ nfrontp += copied;
127+ len -= copied;
128+ remaining -= copied;
129+ buf += copied;
130+ }
131+ return;
132+}
133+
134+/**
135 void
136 netoprintf(const char *fmt, ...)
137 {
138@@ -67,7 +116,7 @@ netoprintf(const char *fmt, ...)
139 va_end(ap);
140
141 if (len<0 || len==maxsize) {
142- /* didn't fit */
143+ / * did not fit * /
144 netflush();
145 }
146 else {
147@@ -76,6 +125,7 @@ netoprintf(const char *fmt, ...)
148 }
149 nfrontp += len;
150 }
151+*/
152
153 /*
154 * ttloop
155@@ -273,10 +323,15 @@ netflush(void)
156 int n;
157
158 if ((n = nfrontp - nbackp) > 0) {
159+
160+#if 0
161+ /* XXX This causes output_data() to recurse and die */
162 DIAG(TD_REPORT,
163 { netoprintf("td: netflush %d chars\r\n", n);
164 n = nfrontp - nbackp; /* update count */
165 });
166+#endif
167+
168 #if defined(ENCRYPT)
169 if (encrypt_output) {
170 char *s = nclearto ? nclearto : nbackp;
171@@ -310,11 +365,14 @@ netflush(void)
172 }
173 }
174 }
175- if (n < 0) {
176- if (errno == EWOULDBLOCK || errno == EINTR)
177- return;
178- cleanup(0);
179- }
180+
181+ if (n == -1) {
182+ if (errno == EWOULDBLOCK || errno == EINTR)
183+ return;
184+ cleanup(0);
185+ /* NOTREACHED */
186+ }
187+
188 nbackp += n;
189 #if defined(ENCRYPT)
190 if (nbackp > nclearto)
191@@ -332,7 +390,7 @@ netflush(void)
192 return;
193 } /* end of netflush */
194
195-
196+#if 0
197 /*
198 * writenet
199 *
200@@ -355,7 +413,7 @@ void writenet(register unsigned char *pt
201 nfrontp += len;
202
203 } /* end of writenet */
204-
205+#endif
206
207 /*
208 * miscellaneous functions doing a variety of little jobs follow ...