telnetd: fix compile problem for non-standalone telnetd
This commit is contained in:
parent
c021cb08b5
commit
81c6a91251
@ -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)
|
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;
|
size_t wr, rc, total;
|
||||||
|
|
||||||
total = 0;
|
total = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return total;
|
return total;
|
||||||
if (*buf == (char)0xff) {
|
if (*buf == (char)IAC) {
|
||||||
rc = safe_write(fd, "\xff\xff", 2);
|
static const char IACIAC[] ALIGN1 = { IAC, IAC };
|
||||||
|
rc = safe_write(fd, IACIAC, 2);
|
||||||
if (rc != 2)
|
if (rc != 2)
|
||||||
break;
|
break;
|
||||||
buf++;
|
buf++;
|
||||||
@ -177,11 +178,11 @@ static size_t iac_safe_write(int fd, const char *buf, size_t count)
|
|||||||
count--;
|
count--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* count != 0, *buf != 0xff */
|
/* count != 0, *buf != IAC */
|
||||||
oxff = memchr(buf, 0xff, count);
|
IACptr = memchr(buf, IAC, count);
|
||||||
wr = count;
|
wr = count;
|
||||||
if (oxff)
|
if (IACptr)
|
||||||
wr = oxff - buf;
|
wr = IACptr - buf;
|
||||||
rc = safe_write(fd, buf, wr);
|
rc = safe_write(fd, buf, wr);
|
||||||
if (rc != wr)
|
if (rc != wr)
|
||||||
break;
|
break;
|
||||||
@ -255,9 +256,13 @@ make_new_session(
|
|||||||
//memcpy(TS_BUF2, iacs_to_send, sizeof(iacs_to_send));
|
//memcpy(TS_BUF2, iacs_to_send, sizeof(iacs_to_send));
|
||||||
//ts->rdidx2 = sizeof(iacs_to_send);
|
//ts->rdidx2 = sizeof(iacs_to_send);
|
||||||
//ts->size2 = 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));
|
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;*/
|
/*ts->size2 = 0;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user