From 10cf5a538f5661d06328ec36c21d7c491ad27408 Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Fri, 16 Feb 2018 13:18:08 -0500 Subject: [PATCH] Ticket 49568 - Fix integer overflow on 32bit platforms Bug Description: When generating the nsState information for the uniqueid generator the timestamp was overflowing on arm(and possibly other 32 bit platforms). This then broke the upgrade setup code when 50fixNsState.pl was ran. 50fixNsState script also incorrectly converts 64bit nsState value to 32 bit Fix Description: Cast the current time (time_t) to the proper type when when calculating the time since epoch. Also do not convert nsState during upgrade if it is already 64bit value. https://pagure.io/389-ds-base/issue/49568 Reviewed by: ? --- ldap/admin/src/scripts/50fixNsState.pl | 3 ++- ldap/servers/slapd/uuid.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ldap/admin/src/scripts/50fixNsState.pl b/ldap/admin/src/scripts/50fixNsState.pl index bd2070808..f825bbaca 100644 --- a/ldap/admin/src/scripts/50fixNsState.pl +++ b/ldap/admin/src/scripts/50fixNsState.pl @@ -41,9 +41,11 @@ sub convert_uniqueid { my $bigfmt64 = "NNA6nC"; my $fmt = $fmt32; my $bigfmt = $bigfmt32; + my $packfmt = $packfmt32; if (length($val) > 20) { $fmt = $fmt64; $bigfmt = $bigfmt64; + $packfmt = $packfmt64; } elsif ($is64) { # cannot convert 32-bit to 64-bit - just delete the entry and continue debug(1, "Cannot convert 32-bit nsState value $hex to 64-bit - deleting entry " . @@ -59,7 +61,6 @@ sub convert_uniqueid { $packfmt64 = "NNA6nCx7"; } - my $packfmt = $packfmt32; if ($is64) { $packfmt = $packfmt64; } diff --git a/ldap/servers/slapd/uuid.c b/ldap/servers/slapd/uuid.c index df86f06c0..a8bd6ee6c 100644 --- a/ldap/servers/slapd/uuid.c +++ b/ldap/servers/slapd/uuid.c @@ -872,7 +872,7 @@ get_system_time(uuid_time_t *uuid_time) /* Offset between UUID formatted times and time() formatted times. UUID UTC base time is October 15, 1582. time() base time is January 1, 1970.*/ - *uuid_time = cur_time * SEQ_PER_SEC + I64(0x01B21DD213814000); + *uuid_time = (uuid_time_t)cur_time * SEQ_PER_SEC + I64(0x01B21DD213814000); } /* ONREPL */ -- 2.13.6