diff --git a/bbs.c b/bbs.c index 1b5d645..756c1fe 100644 --- a/bbs.c +++ b/bbs.c @@ -284,10 +284,20 @@ char s_getchar() { usertimeout = 10; return c; } - len = read(gSocket, &c, 1); - if (len == 0) { - disconnect("Socket Closed"); - } + if (c == 254 || c == 253 || c == 252 || c == 251) { + len = read(gSocket, &c, 1); + if (len == 0) { + disconnect("Socket Closed"); + } + } else if (c == 250) { + do { + len = read(gSocket, &c, 1); + if (len == 0) { + disconnect("Socket Closed"); + } + } while(c != 240); + } + len = read(gSocket, &c, 1); if (len == 0) { disconnect("Socket Closed"); @@ -376,7 +386,7 @@ void s_readpass(char *buffer, int max) { } void disconnect(char *calledby) { - char buffer[256]; + char buffer[1024]; if (gUser != NULL) { save_user(gUser); } @@ -567,10 +577,16 @@ void runbbs_real(int socket, char *ip, int ssh) { ipaddress = ip; if (!ssh) { - write(socket, iac_echo, 3); - write(socket, iac_sga, 3); gUser = NULL; sshBBS = 0; + if (write(socket, iac_echo, 3) != 3) { + dolog("Failed to send iac_echo"); + exit(0); + } + if (write(socket, iac_sga, 3) != 3) { + dolog("Failed to send iac_sga"); + exit(0); + } } else { sshBBS = 1; } diff --git a/doors.c b/doors.c index 0670b29..36b4ff3 100644 --- a/doors.c +++ b/doors.c @@ -277,11 +277,22 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c gotiac = 1; } } else { - if (gotiac < 2 && gotiac != 0) { - gotiac++; - } else { - write(master, &c, 1); + if (gotiac == 1) { + if (c == 254 || c == 253 || c == 252 || c == 251) { + gotiac = 2; + } else if (c == 250) { + gotiac = 3; + } else { + gotiac = 0; + } + } else if (gotiac == 2) { gotiac = 0; + } else if (gotiac == 3) { + if (c == 240) { + gotiac = 0; + } + } else { + write(master, &c, 1); } } } else if (FD_ISSET(master, &fdset)) {