1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

ridalloc: Don't skip the first RID of a pool

Previously, if either of the rIDPreviousAllocation and rIDNextRID
attributes were not present in a RID Set, the first RID in
rIDAllocationPool was skipped over when determining their values.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
Joseph Sutton 2021-06-01 12:03:38 +12:00 committed by Andrew Bartlett
parent 59d293b606
commit 2a3b82ae23
3 changed files with 6 additions and 6 deletions

View File

@ -1469,7 +1469,7 @@ schemaUpdateNow: 1
if prev_pool == uint64_max or next_rid == uint32_max:
prev_pool = alloc_pool
next_rid = prev_pool & uint32_max
else:
next_rid += 1
# Now check if our current pool is still usable

View File

@ -136,10 +136,9 @@ class DsdbTests(TestCase):
"rIDAllocationPool"))
self.samdb.modify(msg)
# Ensure that next_free_rid() returns the start of the next pool
# plus one.
# Ensure that next_free_rid() returns the start of the next pool.
next_free_rid3 = self.samdb.next_free_rid()
self.assertEqual(next_lo + 1, next_free_rid3)
self.assertEqual(next_lo, next_free_rid3)
# Check the result of allocate_rid() matches.
rid = self.samdb.allocate_rid()

View File

@ -594,12 +594,13 @@ int ridalloc_allocate_rid(struct ldb_module *module, uint32_t *rid, struct ldb_r
nridset.next_rid == UINT32_MAX) {
nridset.prev_pool = nridset.alloc_pool;
nridset.next_rid = nridset.prev_pool & 0xFFFFFFFF;
} else {
nridset.next_rid += 1;
}
/*
* Now check if our current pool is still usable
*/
nridset.next_rid += 1;
prev_pool_lo = nridset.prev_pool & 0xFFFFFFFF;
prev_pool_hi = nridset.prev_pool >> 32;
if (nridset.next_rid > prev_pool_hi) {