Blame SOURCES/telnet-0.17-sa-01-49.patch

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