Improved IAC non-handling :)

This commit is contained in:
Andrew Pamment 2016-12-12 11:32:57 +10:00
parent eb3e68388f
commit f031dc37be
2 changed files with 38 additions and 11 deletions

30
bbs.c
View File

@ -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;
}

19
doors.c
View File

@ -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)) {