From 040dfa51fae7b1fd6eb66ab2564ce35be17ae619 Mon Sep 17 00:00:00 2001 From: Mark Cavage Date: Mon, 9 Jan 2012 08:24:14 -0800 Subject: [PATCH] GH-47 Server crash in c.on('data') --- lib/server.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/server.js b/lib/server.js index c916e8e..9bc4b15 100644 --- a/lib/server.js +++ b/lib/server.js @@ -423,7 +423,17 @@ function Server(options) { c.on('data', function(data) { if (log.isTraceEnabled()) log.trace('data on %s: %s', c.ldap.id, util.inspect(data)); - c.parser.write(data); + + try { + c.parser.write(data); + } catch (e) { + log.warn('Unable to parse message [c.on(\'data\')]: %s', e.stack); + c.end(new LDAPResult({ + status: 0x02, + errorMessage: e.toString(), + connection: c + }).toBer()); + } }); }; // end newConnection