* Fix bug causing asserts with many clients in telnet server

This commit is contained in:
Bryan Ashby 2015-07-06 18:26:42 -06:00
parent aea6782f8c
commit 2b963ce6f9

View file

@ -432,15 +432,16 @@ function TelnetClient(input, output) {
var i; var i;
while((i = bufs.indexOf(IAC_BUF)) >= 0) { while((i = bufs.indexOf(IAC_BUF)) >= 0) {
/*
if(bufs.length < (i + 1)) { //
// Some clients will send even IAC separate from data
//
if(bufs.length <= (i + 1)) {
i = MORE_DATA_REQUIRED; i = MORE_DATA_REQUIRED;
break; break;
} }
*/
// :TODO: Android client Irssi ConnectBot asserts here: assert(bufs.length > (i + 1));
assert(bufs.length > (i + 1),
'bufs.length=' + bufs.length + ' i=' + i + ' bufs=' + require('../string_util.js').debugEscapedString(bufs.toBuffer()))
if(i > 0) { if(i > 0) {
self.emit('data', bufs.splice(0, i).toBuffer()); self.emit('data', bufs.splice(0, i).toBuffer());
@ -451,9 +452,6 @@ function TelnetClient(input, output) {
if(MORE_DATA_REQUIRED === i) { if(MORE_DATA_REQUIRED === i) {
break; break;
} else { } else {
//self.emit('event', i); // generic event
//self.emit(i.command, i); // "will", "wont", ...
if(i.option) { if(i.option) {
self.emit(i.option, i); // "transmit binary", "echo", ... self.emit(i.option, i); // "transmit binary", "echo", ...
} }