Improve parser error handling

In cases where one side of the connection is not communicated with valid
ASN.1/BER, it would be better to fire an error event rather than let the
exception bubble all the way up.

Fix mcavage/node-ldapjs#142
This commit is contained in:
Patrick Mooney 2014-03-15 16:06:42 -05:00
parent d20308265a
commit 7c7c480eb8
1 changed files with 8 additions and 2 deletions

View File

@ -113,8 +113,14 @@ Parser.prototype.getMessage = function (ber) {
var self = this;
try {
var messageID = ber.readInt();
var type = ber.readSequence();
} catch (e) {
// Handle servers that aren't speaking the language at all
this.emit('error', e);
return false;
}
var Message;
switch (type) {