aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-11-12 21:14:50 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-11-12 21:14:50 +0000
commit81c6a91251016da8a2cce2ceaf01f4e322711899 (patch)
tree0da40b0482a0d9d7b41619cff718d9e3b91c9b47
parentc021cb08b58dee7480fe6035d8ac00f0dbe83188 (diff)
downloadbusybox-81c6a91251016da8a2cce2ceaf01f4e322711899.tar.gz
telnetd: fix compile problem for non-standalone telnetd
-rw-r--r--networking/telnetd.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/networking/telnetd.c b/networking/telnetd.c
index f04b32f9e..481c932db 100644
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
@@ -157,19 +157,20 @@ remove_iacs(struct tsession *ts, int *pnum_totty)
}
/*
- * Converting single 0xff into double on output
+ * Converting single IAC into double on output
*/
static size_t iac_safe_write(int fd, const char *buf, size_t count)
{
- const char *oxff;
+ const char *IACptr;
size_t wr, rc, total;
total = 0;
while (1) {
if (count == 0)
return total;
- if (*buf == (char)0xff) {
- rc = safe_write(fd, "\xff\xff", 2);
+ if (*buf == (char)IAC) {
+ static const char IACIAC[] ALIGN1 = { IAC, IAC };
+ rc = safe_write(fd, IACIAC, 2);
if (rc != 2)
break;
buf++;
@@ -177,11 +178,11 @@ static size_t iac_safe_write(int fd, const char *buf, size_t count)
count--;
continue;
}
- /* count != 0, *buf != 0xff */
- oxff = memchr(buf, 0xff, count);
+ /* count != 0, *buf != IAC */
+ IACptr = memchr(buf, IAC, count);
wr = count;
- if (oxff)
- wr = oxff - buf;
+ if (IACptr)
+ wr = IACptr - buf;
rc = safe_write(fd, buf, wr);
if (rc != wr)
break;
@@ -255,9 +256,13 @@ make_new_session(
//memcpy(TS_BUF2, iacs_to_send, sizeof(iacs_to_send));
//ts->rdidx2 = sizeof(iacs_to_send);
//ts->size2 = sizeof(iacs_to_send);
- /* So just stuff it into TCP buffer! */
+ /* So just stuff it into TCP stream! (no error check...) */
+#if ENABLE_FEATURE_TELNETD_STANDALONE
safe_write(sock, iacs_to_send, sizeof(iacs_to_send));
- /*ts->rdidx2 = 0; - xzalloc did it! */
+#else
+ safe_write(1, iacs_to_send, sizeof(iacs_to_send));
+#endif
+ /*ts->rdidx2 = 0; - xzalloc did it */
/*ts->size2 = 0;*/
}