From e2cac51a295db1969cc4e69d9b333f4215f5c2af Mon Sep 17 00:00:00 2001 From: Mark Cavage Date: Mon, 26 Sep 2011 13:47:33 -0700 Subject: [PATCH] GH-18: Server not handling unknown message types gracefull --- lib/messages/parser.js | 3 ++- lib/server.js | 11 +++++++---- package.json | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/messages/parser.js b/lib/messages/parser.js index f75670b..b0cf647 100644 --- a/lib/messages/parser.js +++ b/lib/messages/parser.js @@ -222,7 +222,8 @@ Parser.prototype._newMessage = function(ber) { default: var e = new Error('protocolOp 0x' + type.toString(16) + ' not supported'); this.emit('error', e, new LDAPResult({ - messageID: messageID + messageID: messageID, + protocolOp: type })); this._reset(); return false; diff --git a/lib/server.js b/lib/server.js index 69458af..add49c1 100644 --- a/lib/server.js +++ b/lib/server.js @@ -378,10 +378,13 @@ function Server(options) { c.ldap.id, err.stack); var res = getResponse(message); - - res.status = 0x02; // protocol error - res.errorMessage = err.toString(); - c.end(res.toBer()); + if (res) { + res.status = 0x02; // protocol error + res.errorMessage = err.toString(); + c.end(res.toBer()); + } else { + c.destroy(); + } }); c.on('data', function(data) { diff --git a/package.json b/package.json index c052593..ba59aee 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "name": "ldapjs", "homepage": "http://ldapjs.org", "description": "LDAP client and server APIs", - "version": "0.1.5", + "version": "0.1.6", "repository": { "type": "git", "url": "git://github.com/mcavage/node-ldapjs.git"