int consec_8bit_chars = 0;
const unsigned char* start = buf.data;
+ unsigned int max_buf = 0;
buf.len = 0;
/* Telnet commands are handled in here.
write_ptr--;
buf.len--;
- if ((*write_ptr == CR) &&
+ if ((*write_ptr == CR) && (write_ptr + 1 < start + max_buf) &&
((*(write_ptr+1) == NUL) || (*(write_ptr+1) == LF)) )
{
/* Okay, found the CR NUL or CR LF, move it
{
write_ptr+=2;
buf.len+=2;
+ max_buf = (buf.len > max_buf) ? buf.len : max_buf;
}
break;
}
read_ptr++; /* skip past the first IAC */
*write_ptr++ = *read_ptr++;
buf.len++;
+ max_buf = (buf.len > max_buf) ? buf.len : max_buf;
break;
case TNC_WILL:
case TNC_WONT:
default:
*write_ptr++ = *read_ptr++;
buf.len++;
+ max_buf = (buf.len > max_buf) ? buf.len : max_buf;
break;
}