From: Pierangelo Masarati Date: Thu, 4 Oct 2007 22:02:08 +0000 (+0000) Subject: import fix to ITS#5168 X-Git-Tag: OPENLDAP_REL_ENG_2_3_39~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e55fce629b80d3cda10d1fc669893b805fb46236;p=thirdparty%2Fopenldap.git import fix to ITS#5168 --- diff --git a/CHANGES b/CHANGES index 5c3cad3ddb..ee915c3f56 100644 --- a/CHANGES +++ b/CHANGES @@ -15,6 +15,7 @@ OpenLDAP 2.3.39 Engineering Fixed slapo-pcache and -rwm interaction fix (ITS#4991) Fixed slapo-pcache non-null terminated array crasher (ITS#5163) Fixed slapo-rwm modlist handling (ITS#5124) + Fixed slapo-rwm UUID in filter (ITS#5168) Fixed liblber Windows x64 portability (ITS#5105) Fixed libldap ppolicy control creation (ITS#5103) Build Environment diff --git a/include/lutil.h b/include/lutil.h index 6b2bf76bef..5ca432539c 100644 --- a/include/lutil.h +++ b/include/lutil.h @@ -212,6 +212,13 @@ lutil_pair( ber_socket_t sd[2] ); LDAP_LUTIL_F( size_t ) lutil_uuidstr( char *buf, size_t len ); +LDAP_LUTIL_F( int ) +lutil_uuidstr_from_normalized( + char *uuid, + size_t uuidlen, + char *buf, + size_t buflen ); + /* csn.c */ /* use this macro to allocate buffer for lutil_csnstr */ #define LDAP_LUTIL_CSNSTR_BUFSIZE 64 diff --git a/libraries/liblutil/uuid.c b/libraries/liblutil/uuid.c index e2bbe74ad6..61b03b6bce 100644 --- a/libraries/liblutil/uuid.c +++ b/libraries/liblutil/uuid.c @@ -371,6 +371,47 @@ lutil_uuidstr( char *buf, size_t len ) #endif } +int +lutil_uuidstr_from_normalized( + char *uuid, + size_t uuidlen, + char *buf, + size_t buflen ) +{ + unsigned char nibble; + int i, d = 0; + + assert( uuid != NULL ); + assert( buf != NULL ); + + if ( uuidlen != 16 ) return -1; + if ( buflen < 36 ) return -1; + + for ( i = 0; i < 16; i++ ) { + if ( i == 4 || i == 6 || i == 8 || i == 10 ) { + buf[(i<<1)+d] = '-'; + d += 1; + } + + nibble = (uuid[i] >> 4) & 0xF; + if ( nibble < 10 ) { + buf[(i<<1)+d] = nibble + '0'; + } else { + buf[(i<<1)+d] = nibble - 10 + 'a'; + } + + nibble = (uuid[i]) & 0xF; + if ( nibble < 10 ) { + buf[(i<<1)+d+1] = nibble + '0'; + } else { + buf[(i<<1)+d+1] = nibble - 10 + 'a'; + } + } + + if ( buflen > 36 ) buf[36] = '\0'; + return 36; +} + #ifdef TEST int main(int argc, char **argv) diff --git a/servers/slapd/overlays/rwmmap.c b/servers/slapd/overlays/rwmmap.c index 36d8165ee3..e0cc157683 100644 --- a/servers/slapd/overlays/rwmmap.c +++ b/servers/slapd/overlays/rwmmap.c @@ -32,6 +32,7 @@ #include "slap.h" #include "rwm.h" +#include "lutil.h" #undef ldap_debug /* silence a warning in ldap-int.h */ #include "../../../libraries/libldap/ldap-int.h" @@ -382,6 +383,7 @@ map_attr_value( { struct berval vtmp = BER_BVNULL; int freeval = 0; + char uuid[ LDAP_LUTIL_UUIDSTR_BUFSIZE ]; AttributeDescription *ad = *adp; struct ldapmapping *mapping = NULL; @@ -425,6 +427,14 @@ map_attr_value( return -1; } + } else if ( ad->ad_type->sat_syntax == slap_schema.si_ad_entryUUID->ad_type->sat_syntax ) { + vtmp.bv_len = lutil_uuidstr_from_normalized( value->bv_val, + value->bv_len, uuid, LDAP_LUTIL_UUIDSTR_BUFSIZE ); + if ( vtmp.bv_len < 0 ) { + return -1; + } + vtmp.bv_val = uuid; + } else if ( ad == slap_schema.si_ad_objectClass || ad == slap_schema.si_ad_structuralObjectClass ) {