summaryrefslogtreecommitdiffstats
path: root/ldap
diff options
context:
space:
mode:
authorRich Megginson <rmeggins@redhat.com>2007-10-13 01:47:15 +0000
committerRich Megginson <rmeggins@redhat.com>2007-10-13 01:47:15 +0000
commitf21456587bd4b0dcc23b45cd026efa4cc25496f9 (patch)
treef418fccf70d9ba0146569d9b1c372b979007625c /ldap
parentee385e64f9dff2f36ffa8eebd872f98aadcffbdb (diff)
downloadds-f21456587bd4b0dcc23b45cd026efa4cc25496f9.tar.gz
ds-f21456587bd4b0dcc23b45cd026efa4cc25496f9.tar.xz
ds-f21456587bd4b0dcc23b45cd026efa4cc25496f9.zip
Resolves: bug 330121
Bug Description: uuid generator truncates clock_seq_hi_and_reserved field Reviewed by: nkinder (Thanks!) Fix Description: The uuid code has this code (where clock_seq is unsigned16 - 2 bytes and uuid->clock_seq_hi_and_reserved is unsigned8 - 1 byte): uuid->clock_seq_hi_and_reserved = (unsigned8)(clock_seq & 0x3F00) >> 8; In this code, the cast to unsigned8 takes precedence over over the shift. So what happens is that (clock_seq & 0x3F00) is first cast to an 8 bit quantity, then shifted by 8 bits. The result is that the value is _always 0_. The code also does this: uuid->clock_seq_hi_and_reserved |= 0x80; You can see this because every nsUniqueID looks like this: XXXXXXXX-XXXXXXXX-80XXXXXXXX-XXXXXXXX The first byte of the 3rd octet is always 80. This may also be related to https://bugzilla.redhat.com/show_bug.cgi?id=197886 and may explain why the sequence numbers were exhausted so quickly. Without this fix, we only have 256 sequence numbers available. This fix adds another 6 bits. The fix is to mask and shift as an unsigned16 quantity, then cast to unsigned8. Platforms tested: RHEL5 x86_64 Flag Day: no - I think this will only impact new unique IDs that are generated. It will not affect existing unique IDs. Doc impact: no
Diffstat (limited to 'ldap')
-rw-r--r--ldap/servers/slapd/uuid.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ldap/servers/slapd/uuid.c b/ldap/servers/slapd/uuid.c
index 3089de09..2bc3c701 100644
--- a/ldap/servers/slapd/uuid.c
+++ b/ldap/servers/slapd/uuid.c
@@ -842,7 +842,7 @@ static void format_uuid_v1(guid_t * uuid, uuid_time_t timestamp, unsigned16 cloc
((timestamp >> 48) & 0x0FFF);
uuid->time_hi_and_version |= (1 << 12);
uuid->clock_seq_low = clock_seq & 0xFF;
- uuid->clock_seq_hi_and_reserved = (unsigned8)(clock_seq & 0x3F00) >> 8;
+ uuid->clock_seq_hi_and_reserved = (unsigned8)((clock_seq & 0x3F00) >> 8);
uuid->clock_seq_hi_and_reserved |= 0x80;
memcpy(&uuid->node, &_state.genstate.node, sizeof (uuid->node));
}