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;
}
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->bv_val, 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,
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;
}
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;
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)
bio = BIO_new(BIO_s_mem());
if ( !bio ) {
- fprintf(stderr, ERR_error_string(ERR_get_error(),NULL));
- /* ERR_print_errors(bio_err); */
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY,
+ "dn_openssl2ldap: error creating BIO_s_mem: %s\n",
+ ERR_error_string(ERR_get_error(),NULL)));
+#else
+ Debug( LDAP_DEBUG_ARGS, "dn_openssl2ldap: "
+ "error creating BIO: %s\n",
+ ERR_error_string(ERR_get_error(),NULL), NULL, NULL );
+#endif
return NULL;
}
X509_NAME_print_ex(bio, name, 0, XN_FLAG_RFC2253);
xcert = d2i_X509(NULL, &p, in->bv_len);
if ( !xcert ) {
- ERR_error_string(ERR_get_error(),NULL);
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY,
+ "certificateExactConvert: error parsing cert: %s\n",
+ ERR_error_string(ERR_get_error(),NULL)));
+#else
+ Debug( LDAP_DEBUG_ARGS, "certificateExactConvert: "
+ "error parsing cert: %s\n",
+ ERR_error_string(ERR_get_error(),NULL), NULL, NULL );
+#endif
return LDAP_INVALID_SYNTAX;
}
serial = asn1_integer2str(xcert->cert_info->serialNumber);
+ if ( !serial ) {
+ X509_free(xcert);
+ return LDAP_INVALID_SYNTAX;
+ }
issuer_dn = dn_openssl2ldap(X509_get_issuer_name(xcert));
+ if ( !issuer_dn ) {
+ X509_free(xcert);
+ ber_bvfree(serial);
+ return LDAP_INVALID_SYNTAX;
+ }
+ /* Actually, dn_openssl2ldap returns in a normalized format, but
+ it is different from our normalized format */
+ bv_tmp = issuer_dn;
+ if ( dnNormalize(NULL, bv_tmp, &issuer_dn) != LDAP_SUCCESS ) {
+ X509_free(xcert);
+ ber_bvfree(serial);
+ ber_bvfree(bv_tmp);
+ return LDAP_INVALID_SYNTAX;
+ }
+ ber_bvfree(bv_tmp);
X509_free(xcert);
q = ch_malloc( (end-begin+1)+1 );
AC_MEMCPY( q, begin, end-begin+1 );
q[end-begin+1] = '\0';
- *issuer_dn = ber_bvstr(q);
+ *issuer_dn = ber_bvstr(dn_normalize(q));
return LDAP_SUCCESS;
}
xcert = d2i_X509(NULL, &p, value->bv_len);
if ( !xcert ) {
- ERR_error_string(ERR_get_error(),NULL);
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY,
+ "certificateExactMatch: error parsing cert: %s\n",
+ ERR_error_string(ERR_get_error(),NULL)));
+#else
+ Debug( LDAP_DEBUG_ARGS, "certificateExactMatch: "
+ "error parsing cert: %s\n",
+ ERR_error_string(ERR_get_error(),NULL), NULL, NULL );
+#endif
return LDAP_INVALID_SYNTAX;
}
return ret;
}
+
+/*
+ * Index generation function
+ * We just index the serials, in most scenarios the issuer DN is one of
+ * a very small set of values.
+ */
+int certificateExactIndexer(
+ slap_mask_t use,
+ slap_mask_t flags,
+ Syntax *syntax,
+ MatchingRule *mr,
+ struct berval *prefix,
+ struct berval **values,
+ struct berval ***keysp )
+{
+ int i;
+ struct berval **keys;
+ X509 *xcert;
+ unsigned char *p;
+ struct berval * serial;
+
+ /* we should have at least one value at this point */
+ assert( values != NULL && values[0] != NULL );
+
+ for( i=0; values[i] != NULL; i++ ) {
+ /* empty -- just count them */
+ }
+
+ keys = ch_malloc( sizeof( struct berval * ) * (i+1) );
+
+ for( i=0; values[i] != NULL; i++ ) {
+ p = values[i]->bv_val;
+ xcert = d2i_X509(NULL, &p, values[i]->bv_len);
+ if ( !xcert ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY,
+ "certificateExactIndexer: error parsing cert: %s\n",
+ ERR_error_string(ERR_get_error(),NULL)));
+#else
+ Debug( LDAP_DEBUG_ARGS, "certificateExactIndexer: "
+ "error parsing cert: %s\n",
+ ERR_error_string(ERR_get_error(),NULL),
+ NULL, NULL );
+#endif
+ /* Do we leak keys on error? */
+ return LDAP_INVALID_SYNTAX;
+ }
+
+ serial = asn1_integer2str(xcert->cert_info->serialNumber);
+ X509_free(xcert);
+ integerNormalize( slap_schema.si_syn_integer,
+ serial,
+ &keys[i] );
+ ber_bvfree(serial);
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY,
+ "certificateExactIndexer: returning: %s\n",
+ keys[i]->bv_val));
+#else
+ Debug( LDAP_DEBUG_ARGS, "certificateExactIndexer: "
+ "returning: %s\n",
+ keys[i]->bv_val,
+ NULL, NULL );
+#endif
+ }
+
+ keys[i] = NULL;
+ *keysp = keys;
+ return LDAP_SUCCESS;
+}
+
+/* Index generation function */
+/* We think this is always called with a value in matching rule syntax */
+int certificateExactFilter(
+ slap_mask_t use,
+ slap_mask_t flags,
+ Syntax *syntax,
+ MatchingRule *mr,
+ struct berval *prefix,
+ void * assertValue,
+ struct berval ***keysp )
+{
+ struct berval **keys;
+ struct berval *asserted_serial;
+ struct berval *asserted_issuer_dn;
+
+ serial_and_issuer_parse(assertValue,
+ &asserted_serial,
+ &asserted_issuer_dn);
+
+ keys = ch_malloc( sizeof( struct berval * ) * 2 );
+ integerNormalize( syntax, asserted_serial, &keys[0] );
+ keys[1] = NULL;
+ *keysp = keys;
+
+ ber_bvfree(asserted_serial);
+ ber_bvfree(asserted_issuer_dn);
+ return LDAP_SUCCESS;
+}
#endif
static int
{"( 1.3.6.1.4.1.1466.115.121.1.26 DESC 'IA5 String' )",
0, IA5StringValidate, IA5StringNormalize, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.27 DESC 'Integer' )",
- 0, integerValidate, integerNormalize, integerPretty},
+ 0, integerValidate, integerNormalize, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.28 DESC 'JPEG' " X_NOT_H_R ")",
SLAP_SYNTAX_BLOB, blobValidate, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.29 DESC 'Master And Shadow Access Points' )",
{"( 1.3.6.1.4.1.1466.115.121.1.51 DESC 'Teletex Terminal Identifier' )",
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.52 DESC 'Telex Number' )",
- 0, printableStringValidate, IA5StringNormalize, NULL},
+ 0, printablesStringValidate, IA5StringNormalize, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.53 DESC 'UTC Time' )",
0, utcTimeValidate, utcTimeNormalize, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.54 DESC 'LDAP Syntax Description' )",
"SYNTAX 1.2.826.0.1.3344810.7.1 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT,
certificateExactConvert, NULL,
- certificateExactMatch, NULL, NULL,
+ certificateExactMatch,
+ certificateExactIndexer, certificateExactFilter,
NULL},
#endif
schema_init_done = 1;
return LDAP_SUCCESS;
}
+
+void
+schema_destroy( void )
+{
+ oc_destroy();
+ at_destroy();
+ mr_destroy();
+ syn_destroy();
+}