Merge branch 'master' into clientFix

This commit is contained in:
Tony Brix 2021-08-03 10:07:44 -05:00 committed by GitHub
commit bab1dfcf4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View File

@ -60,7 +60,7 @@ ModifyDNRequest.prototype._toBer = function (ber) {
const len = Buffer.byteLength(s)
ber.writeByte(0x80) // MODIFY_DN_REQUEST_NEW_SUPERIOR_TAG
ber.writeByte(len)
ber.writeLength(len)
ber._ensure(len)
ber._buf.write(s, ber._offset)
ber._offset += len

View File

@ -728,6 +728,34 @@ tap.test('modify DN excessive length (GH-480)', function (t) {
})
})
tap.test('modify DN excessive superior length', function (t) {
const { BerReader, BerWriter } = require('asn1')
const ModifyDNRequest = require('../lib/messages/moddn_request')
const ber = new BerWriter()
const entry = 'cn=Test User,ou=A Long OU ,ou=Another Long OU ,ou=Another Long OU ,dc=acompany,DC=io'
const newSuperior = 'ou=A New Long OU , ou=Another New Long OU , ou=An OU , dc=acompany, dc=io'
const newRdn = entry.replace(/(.*?),.*/, '$1')
const deleteOldRdn = true
const req = new ModifyDNRequest({
entry: entry,
deleteOldRdn: deleteOldRdn,
controls: []
})
req.newRdn = newRdn
req.newSuperior = newSuperior
req._toBer(ber)
const reader = new BerReader(ber.buffer)
t.equal(reader.readString(), entry)
t.equal(reader.readString(), newRdn)
t.equal(reader.readBoolean(), deleteOldRdn)
t.equal(reader.readByte(), 0x80)
reader.readLength()
t.equal(reader._len, newSuperior.length)
reader._buf[--reader._offset] = 0x4
t.equal(reader.readString(), newSuperior)
t.end()
})
tap.test('search basic', function (t) {
t.context.client.search('cn=test, ' + SUFFIX, '(objectclass=*)', function (err, res) {
t.error(err)