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

28
bbs.c
View File

@ -284,10 +284,20 @@ char s_getchar() {
usertimeout = 10; usertimeout = 10;
return c; return c;
} }
len = read(gSocket, &c, 1); if (c == 254 || c == 253 || c == 252 || c == 251) {
if (len == 0) { len = read(gSocket, &c, 1);
disconnect("Socket Closed"); 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); len = read(gSocket, &c, 1);
if (len == 0) { if (len == 0) {
disconnect("Socket Closed"); disconnect("Socket Closed");
@ -376,7 +386,7 @@ void s_readpass(char *buffer, int max) {
} }
void disconnect(char *calledby) { void disconnect(char *calledby) {
char buffer[256]; char buffer[1024];
if (gUser != NULL) { if (gUser != NULL) {
save_user(gUser); save_user(gUser);
} }
@ -567,10 +577,16 @@ void runbbs_real(int socket, char *ip, int ssh) {
ipaddress = ip; ipaddress = ip;
if (!ssh) { if (!ssh) {
write(socket, iac_echo, 3);
write(socket, iac_sga, 3);
gUser = NULL; gUser = NULL;
sshBBS = 0; 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 { } else {
sshBBS = 1; sshBBS = 1;
} }

17
doors.c
View File

@ -277,11 +277,22 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
gotiac = 1; gotiac = 1;
} }
} else { } else {
if (gotiac < 2 && gotiac != 0) { if (gotiac == 1) {
gotiac++; 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 { } else {
write(master, &c, 1); write(master, &c, 1);
gotiac = 0;
} }
} }
} else if (FD_ISSET(master, &fdset)) { } else if (FD_ISSET(master, &fdset)) {