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:
parent
888d34ab7c
commit
48bd7bfe82
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue