From ed7c52c511d3d5ad7b03f523ccd6ac790403ef3e Mon Sep 17 00:00:00 2001 From: Nate Schmolze Date: Mon, 8 Jul 2013 22:32:25 -0400 Subject: [PATCH 1/2] Committing partial fix to receipt of invalid telnet commands. Fix needs to be completed --- lib/telnet.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/telnet.js b/lib/telnet.js index 042e634..e88ec59 100644 --- a/lib/telnet.js +++ b/lib/telnet.js @@ -150,6 +150,9 @@ function parseCommand (bufs, i, event) { var command = bufs.get(i) event.commandCode = command event.command = COMMAND_NAMES[command] + if (event.command === undefined) { + throw "Unsupported command received: " + command; + } return COMMAND_IMPLS[command](bufs, i + 1, event) } @@ -198,7 +201,15 @@ function Socket (input, output) { var data = bufs.splice(0, i).toBuffer() self.emit('data', data) } - i = parse(bufs) + try { + i = parse(bufs); + } catch (e) { + console.log(e); + break; // somehow handle the error. break hangs the entire server; I'm + // guessing that the ctr+c is still in the buffer, and needs to + // be removed. Very new to node, however, so perhaps someone else + // will know how to do that. + } if (i === MORE) { debug('need to wait for more...') break From 73ce974f26e7d33e66f2b14c22fac1e8459270e6 Mon Sep 17 00:00:00 2001 From: Nate Schmolze Date: Mon, 8 Jul 2013 22:35:41 -0400 Subject: [PATCH 2/2] Fixing style issue - tabs to spaces --- lib/telnet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/telnet.js b/lib/telnet.js index e88ec59..793df50 100644 --- a/lib/telnet.js +++ b/lib/telnet.js @@ -204,7 +204,7 @@ function Socket (input, output) { try { i = parse(bufs); } catch (e) { - console.log(e); + console.log(e); break; // somehow handle the error. break hangs the entire server; I'm // guessing that the ctr+c is still in the buffer, and needs to // be removed. Very new to node, however, so perhaps someone else