[BusyBox] telnetd with busybox-sh

Vladimir N. Oleynik dzo at simtreas.ru
Wed Aug 22 10:44:25 UTC 2001


Special patch on motives this dispute:
 
> This is due to sash being able to handle getting random control characters
> spewed at it better than busybox sh.  This is fixed in a patch that I sent
> to the list:
> http://busybox.net/lists/busybox/2001-August/004262.html
> 
> The new funciton of interest is remove_iac().
> 
> BTW. How do people like telnetd, should I apply this?  I haven't gotten a
> definitive answer.

Addition to this for busybox telnet client - parse IAC as IAC IAC, was 
(and at the majority telnet) masking IAC=0xff to 0x7f.
"Special" for windows-cp1251 russian "Ya" (translate to "I") ! ;-)


--w
vodz
-------------- next part --------------
diff -rbu busybox.orig/telnet.c busybox/telnet.c
--- busybox.orig/telnet.c	Tue Jun 26 06:06:08 2001
+++ busybox/telnet.c	Wed Aug 22 20:36:15 2001
@@ -205,20 +205,38 @@
 	 *	not need to be 100% 8-bit clean, so changing every 0xff:s to
 	 *	0x7f:s */
 
-	int i;
-	byte * p = G.buf;
+	int i, nul_ff_counter = 0;
+	char * p = G.buf;
 
 	for (i = len; i > 0; i--, p++)
 	{
-		if (*p == 0x1d)
+		if (*p == '\035')
 		{
 			conescape();
 			return;
 		}
-		if (*p == 0xff)
-			*p = 0x7f;
+
+		if (*p == '\377')
+			nul_ff_counter++;
 	}
-	write(G.netfd, G.buf, len);
+	if(nul_ff_counter) {
+		int lout=0;
+		p=xmalloc(len+nul_ff_counter);
+
+		for(i=0; i<len; i++) {
+			char c = G.buf[i];
+
+			p[lout++] = c;
+			if (c == '\377')
+				p[lout++] = c;
+		}
+		len = lout;
+	} else {
+		p = G.buf;
+	}
+	write(G.netfd, p, len);
+	if(p!=G.buf)
+		free(p);
 }
 
 


More information about the busybox mailing list