--- powwow.c.old Fri Jan 9 14:17:33 1998 +++ powwow.c Tue Jan 20 11:57:55 1998 @@ -710,6 +710,7 @@ char *linestart, *lineend, *end; int mpilen = strlen(MPI); char buf2[LINELEN]; + static int last_was_nl = 0; /* Cosmos: fix MPI-in-whois security hole */ /* process block one line at a time: */ @@ -726,30 +727,44 @@ * also remove extra "\r" before or after "\n" */ int found_nl = 0; /* GH: added to allow \n-ending */ - + linestart = lineend = buf; for (; buf < end; buf++) { if (*buf == '\n') { + /* got a newline: \n */ + last_was_nl = 1; lineend = buf; *buf = '\0'; - if (buf > linestart && buf[-1] == '\r') - buf[-1] = '\0'; + if (buf > linestart && buf[-1] == '\r') { + /* well, it was \r\n . just erase the \r */ + buf[-1] = '\0'; + lineend--; + } + buf++; - while (buf < end && *buf == '\r') - *buf++ = '\0'; + if (buf < end && *buf == '\r') { + /* + * this was \n\r instead. erase the \r as well, + * and also forbid any MPI (MUME kludge) + */ + *buf++ = '\0'; + last_was_nl = 0; + } found_nl = 1; break; } } - if (buf == end && !found_nl) - lineend = end; /* line continues till end of buffer, no trailing \n */ - if (!strncmp(MPI, linestart, mpilen)) { - lineend = linestart + - process_message(linestart + mpilen, - end - linestart - mpilen) + mpilen; + if (last_was_nl && !strncmp(MPI, linestart, mpilen)) { + /* got a MUME MPI message, don't send it to screen! */ + buf = lineend = linestart + mpilen + + process_message(linestart + mpilen, end - linestart - mpilen); continue; } + + if (buf == end && !found_nl) + /* line continues till end of buffer, no trailing \n */ + lineend = end; #ifdef DEBUGCODE_2 /* debug code to see in detail what codes come from the server */