if ( val->bv_len != 0 ) {
char *dn;
- out = ber_bvstr( UTF8normalize( val->bv_val, UTF8_CASEFOLD ) );
+ out = ber_bvstr( UTF8normalize( val, UTF8_CASEFOLD ) );
dn = dn_validate( out->bv_val );
break;
}
}
- if( dn->bv_val[i] != '\'' ) {
- return LDAP_INVALID_SYNTAX;
- }
- if( dn->bv_val[i-1] != 'B' ) {
- return LDAP_INVALID_SYNTAX;
- }
- if( dn->bv_val[i-2] != '#' ) {
+ if( dn->bv_val[i] != '\'' ||
+ dn->bv_val[i-1] != 'B' ||
+ dn->bv_val[i-2] != '#' ) {
+ ber_bvfree( dn );
return LDAP_INVALID_SYNTAX;
}
}
if( sa->sa_initial != NULL ) {
- nsa->sa_initial = ber_bvstr( UTF8normalize( sa->sa_initial->bv_val, casefold ) );
+ nsa->sa_initial = ber_bvstr( UTF8normalize( sa->sa_initial, casefold ) );
if( nsa->sa_initial == NULL ) {
goto err;
}
}
nsa->sa_any = (struct berval **)ch_malloc( (i + 1) * sizeof(struct berval *) );
for( i=0; sa->sa_any[i] != NULL; i++ ) {
- nsa->sa_any[i] = ber_bvstr( UTF8normalize( sa->sa_any[i]->bv_val, casefold ) );
+ nsa->sa_any[i] = ber_bvstr( UTF8normalize( sa->sa_any[i], casefold ) );
if( nsa->sa_any[i] == NULL ) {
goto err;
}
}
if( sa->sa_final != NULL ) {
- nsa->sa_final = ber_bvstr( UTF8normalize( sa->sa_final->bv_val, casefold ) );
+ nsa->sa_final = ber_bvstr( UTF8normalize( sa->sa_final, casefold ) );
if( nsa->sa_final == NULL ) {
goto err;
}
return nsa;
err:
- ch_free( nsa->sa_final );
+ ber_bvfree( nsa->sa_final );
ber_bvecfree( nsa->sa_any );
- ch_free( nsa->sa_initial );
+ ber_bvfree( nsa->sa_initial );
ch_free( nsa );
return NULL;
}
struct berval *value,
void *assertedValue )
{
- char *val, *assertv, **values, **words, *c;
+ char *val, *nval, *assertv, **values, **words, *c;
int i, count, len, nextchunk=0, nextavail=0;
size_t avlen;
/* Yes, this is necessary */
- val = UTF8normalize( value->bv_val, UTF8_NOCASEFOLD );
- if( val == NULL ) {
+ nval = UTF8normalize( value, UTF8_NOCASEFOLD );
+ if( nval == NULL ) {
*matchp = 1;
return LDAP_SUCCESS;
}
- strip8bitChars( val );
+ strip8bitChars( nval );
/* Yes, this is necessary */
- assertv = UTF8normalize( ((struct berval *)assertedValue)->bv_val,
+ assertv = UTF8normalize( ((struct berval *)assertedValue),
UTF8_NOCASEFOLD );
if( assertv == NULL ) {
- free( val );
+ ch_free( nval );
*matchp = 1;
return LDAP_SUCCESS;
}
avlen = strlen( assertv );
/* Isolate how many words there are */
- for( c=val,count=1; *c; c++ ) {
+ for( c=nval,count=1; *c; c++ ) {
c = strpbrk( c, SLAPD_APPROX_DELIMITER );
if ( c == NULL ) break;
*c = '\0';
/* Get a phonetic copy of each word */
words = (char **)ch_malloc( count * sizeof(char *) );
values = (char **)ch_malloc( count * sizeof(char *) );
- for( c=val,i=0; i<count; i++,c+=strlen(c)+1 ) {
+ for( c=nval,i=0; i<count; i++,c+=strlen(c)+1 ) {
words[i] = c;
values[i] = phonetic(c);
}
break;
}
}
+ ch_free( val );
}
/* This chunk in the asserted value was NOT within the *value. */
}
ch_free( values );
ch_free( words );
- free( val );
+ ch_free( nval );
return LDAP_SUCCESS;
}
for( j=0; values[j] != NULL; j++ ) {
/* Yes, this is necessary */
- val = UTF8normalize( values[j]->bv_val, UTF8_NOCASEFOLD );
+ val = UTF8normalize( values[j], UTF8_NOCASEFOLD );
strip8bitChars( val );
/* Isolate how many words there are. There will be a key for each */
struct berval **keys;
/* Yes, this is necessary */
- val = UTF8normalize( ((struct berval *)assertValue)->bv_val,
+ val = UTF8normalize( ((struct berval *)assertValue),
UTF8_NOCASEFOLD );
if( val == NULL ) {
keys = (struct berval **)ch_malloc( sizeof(struct berval *) );
char *s, *t;
/* Yes, this is necessary */
- s = UTF8normalize( value->bv_val, UTF8_NOCASEFOLD );
+ s = UTF8normalize( value, UTF8_NOCASEFOLD );
if( s == NULL ) {
*matchp = 1;
return LDAP_SUCCESS;
}
/* Yes, this is necessary */
- t = UTF8normalize( ((struct berval *)assertedValue)->bv_val,
+ t = UTF8normalize( ((struct berval *)assertedValue),
UTF8_NOCASEFOLD );
if( t == NULL ) {
free( s );
/* Copy each value and run it through phonetic() */
for( i=0; values[i] != NULL; i++ ) {
/* Yes, this is necessary */
- s = UTF8normalize( values[i]->bv_val, UTF8_NOCASEFOLD );
+ s = UTF8normalize( values[i], UTF8_NOCASEFOLD );
/* strip 8-bit chars and run through phonetic() */
keys[i] = ber_bvstr( phonetic( strip8bitChars( s ) ) );
keys = (struct berval **)ch_malloc( sizeof( struct berval * ) * 2 );
/* Yes, this is necessary */
- s = UTF8normalize( ((struct berval *)assertValue)->bv_val,
+ s = UTF8normalize( ((struct berval *)assertValue),
UTF8_NOCASEFOLD );
if( s == NULL ) {
keys[0] = NULL;
casefold = strcmp( mr->smr_oid, caseExactSubstringsMatchOID )
? UTF8_CASEFOLD : UTF8_NOCASEFOLD;
- nav = UTF8normalize( value->bv_val, casefold );
+ nav = UTF8normalize( value, casefold );
if( nav == NULL ) {
match = 1;
goto done;
if( idx >= left.bv_len ) {
/* this shouldn't happen */
+ free( nav );
+ ch_free( sub->sa_final );
+ ber_bvecfree( sub->sa_any );
+ ch_free( sub->sa_initial );
+ ch_free( sub );
return LDAP_OTHER;
}
done:
free( nav );
if( sub != NULL ) {
- ch_free( sub->sa_final );
+ ber_bvfree( sub->sa_final );
ber_bvecfree( sub->sa_any );
- ch_free( sub->sa_initial );
+ ber_bvfree( sub->sa_initial );
ch_free( sub );
}
*matchp = match;
for( i=0; values[i] != NULL; i++ ) {
struct berval *value;
- value = ber_bvstr( UTF8normalize( values[i]->bv_val,
+ value = ber_bvstr( UTF8normalize( values[i],
casefold ) );
HASH_Init( &HASHcontext );
casefold = strcmp( mr->smr_oid, caseExactMatchOID )
? UTF8_CASEFOLD : UTF8_NOCASEFOLD;
- value = ber_bvstr( UTF8normalize( ((struct berval *) assertValue)->bv_val,
+ value = ber_bvstr( UTF8normalize( ((struct berval *) assertValue),
casefold ) );
/* This usually happens if filter contains bad UTF8 */
if( value == NULL ) {
nvalues = ch_malloc( sizeof( struct berval * ) * (i+1) );
for( i=0; values[i] != NULL; i++ ) {
- nvalues[i] = ber_bvstr( UTF8normalize( values[i]->bv_val,
+ nvalues[i] = ber_bvstr( UTF8normalize( values[i],
casefold ) );
}
nvalues[i] = NULL;
if( nkeys == 0 ) {
/* no keys to generate */
*keysp = NULL;
+ ber_bvecfree( nvalues );
return LDAP_SUCCESS;
}
}
if( nkeys == 0 ) {
+ ber_bvfree( sa->sa_final );
+ ber_bvecfree( sa->sa_any );
+ ber_bvfree( sa->sa_initial );
+ ch_free( sa );
*keysp = NULL;
return LDAP_SUCCESS;
}
ch_free( keys );
*keysp = NULL;
}
- ch_free( sa->sa_final );
+ ber_bvfree( sa->sa_final );
ber_bvecfree( sa->sa_any );
- ch_free( sa->sa_initial );
+ ber_bvfree( sa->sa_initial );
ch_free( sa );
return LDAP_SUCCESS;
* Way too large, we need to leave
* room for sign if negative
*/
- return NULL;
+ free(copy);
+ return NULL;
}
*--p = digit[carry];
if (copy[base] == 0)
schema_init_done = 1;
return LDAP_SUCCESS;
}
+
+void
+schema_destroy( void )
+{
+ oc_destroy();
+ at_destroy();
+ mr_destroy();
+ syn_destroy();
+}