Commit e55fce62 authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

import fix to ITS#5168

parent 65ef033e
......@@ -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
......
......@@ -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
......
......@@ -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)
......
......@@ -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 )
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment