Fix message parsing for length-sensitive types

Certain LDAP messages (such as DeleteRequest) encode their contents as
raw bytes within the top-level sequence object.  As such, they rely
their length being passed to them when LDAPMessage decodes the sequence.

This was being done incorrectly, but would not manifest itself as a
problem unless controls followed the message.  If no controls were
present, then length of the sequence item was bounded by the message
itself and the parse would succeed.

Fix mcavage/node-ldapjs#212
This commit is contained in:
Patrick Mooney 2014-07-16 18:53:06 -05:00
parent 888d34ab7c
commit 48bd7bfe82
2 changed files with 14 additions and 1 deletions

View File

@ -66,7 +66,7 @@ LDAPMessage.prototype.parse = function (ber) {
this.log.trace('parse: data=%s', util.inspect(ber.buffer));
// Delegate off to the specific type to parse
this._parse(ber, ber.remain);
this._parse(ber, ber.length);
// Look for controls
if (ber.peek() === 0xa0) {

View File

@ -297,6 +297,19 @@ test('delete success', function (t) {
});
test('delete with control (GH-212)', function (t) {
var control = new ldap.Control({
type: '1.2.3.4',
criticality: false
});
client.del('cn=delete, ' + SUFFIX, control, function (err, res) {
t.ifError(err);
t.ok(res);
t.end();
});
});
test('exop success', function (t) {
client.exop('1.3.6.1.4.1.4203.1.11.3', function (err, value, res) {
t.ifError(err);