From: Kurt Zeilenga Date: Fri, 15 Sep 2000 03:26:22 +0000 (+0000) Subject: Add additional error checking... need to better handle X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1982 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=45cf7e1dfe433fa92123a8ab97df11702e6f5044;p=openldap Add additional error checking... need to better handle garbage input from slapadd or pre-existing database. --- diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 76ccab5c91..5fda4b0992 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -120,12 +120,13 @@ int octetStringIndexer( digest.bv_val = MD5digest; digest.bv_len = sizeof(MD5digest); + /* we should have at least one value at this point */ + assert( values != NULL && values[0] != NULL ); + for( i=0; values[i] != NULL; i++ ) { /* just count them */ } - assert( i > 0 ); - keys = ch_malloc( sizeof( struct berval * ) * (i+1) ); slen = strlen( syntax->ssyn_oid ); @@ -791,12 +792,13 @@ int caseExactIndexer( digest.bv_val = MD5digest; digest.bv_len = sizeof(MD5digest); + /* we should have at least one value at this point */ + assert( values != NULL && values[0] != NULL ); + for( i=0; values[i] != NULL; i++ ) { /* just count them */ } - assert( i > 0 ); - keys = ch_malloc( sizeof( struct berval * ) * (i+1) ); slen = strlen( syntax->ssyn_oid ); @@ -891,6 +893,9 @@ int caseExactSubstringsIndexer( digest.bv_val = MD5digest; digest.bv_len = sizeof(MD5digest); + /* we should have at least one value at this point */ + assert( values != NULL && values[0] != NULL ); + nkeys=0; for( i=0; values[i] != NULL; i++ ) { /* count number of indices to generate */ @@ -922,7 +927,6 @@ int caseExactSubstringsIndexer( } } } - assert( i > 0 ); if( nkeys == 0 ) { /* no keys to generate */ @@ -1358,12 +1362,13 @@ int caseIgnoreIndexer( digest.bv_val = MD5digest; digest.bv_len = sizeof(MD5digest); + /* we should have at least one value at this point */ + assert( values != NULL && values[0] != NULL ); + for( i=0; values[i] != NULL; i++ ) { /* just count them */ } - assert( i > 0 ); - keys = ch_malloc( sizeof( struct berval * ) * (i+1) ); slen = strlen( syntax->ssyn_oid ); @@ -1465,6 +1470,9 @@ int caseIgnoreSubstringsIndexer( digest.bv_val = MD5digest; digest.bv_len = sizeof(MD5digest); + /* we should have at least one value at this point */ + assert( values != NULL && values[0] != NULL ); + nkeys=0; for( i=0; values[i] != NULL; i++ ) { /* count number of indices to generate */ @@ -1496,7 +1504,6 @@ int caseIgnoreSubstringsIndexer( } } } - assert( i > 0 ); if( nkeys == 0 ) { /* no keys to generate */ @@ -2139,12 +2146,13 @@ int caseExactIA5Indexer( digest.bv_val = MD5digest; digest.bv_len = sizeof(MD5digest); + /* we should have at least one value at this point */ + assert( values != NULL && values[0] != NULL ); + for( i=0; values[i] != NULL; i++ ) { /* just count them */ } - assert( i > 0 ); - keys = ch_malloc( sizeof( struct berval * ) * (i+1) ); slen = strlen( syntax->ssyn_oid ); @@ -2239,6 +2247,9 @@ int caseExactIA5SubstringsIndexer( digest.bv_val = MD5digest; digest.bv_len = sizeof(MD5digest); + /* we should have at least one value at this point */ + assert( values != NULL && values[0] != NULL ); + nkeys=0; for( i=0; values[i] != NULL; i++ ) { /* count number of indices to generate */ @@ -2270,7 +2281,6 @@ int caseExactIA5SubstringsIndexer( } } } - assert( i > 0 ); if( nkeys == 0 ) { /* no keys to generate */ @@ -2702,12 +2712,13 @@ int caseIgnoreIA5Indexer( digest.bv_val = MD5digest; digest.bv_len = sizeof(MD5digest); + /* we should have at least one value at this point */ + assert( values != NULL && values[0] != NULL ); + for( i=0; values[i] != NULL; i++ ) { /* just count them */ } - assert( i > 0 ); - keys = ch_malloc( sizeof( struct berval * ) * (i+1) ); slen = strlen( syntax->ssyn_oid ); @@ -2809,6 +2820,9 @@ int caseIgnoreIA5SubstringsIndexer( digest.bv_val = MD5digest; digest.bv_len = sizeof(MD5digest); + /* we should have at least one value at this point */ + assert( values != NULL && values[0] != NULL ); + nkeys=0; for( i=0; values[i] != NULL; i++ ) { /* count number of indices to generate */ @@ -2840,7 +2854,6 @@ int caseIgnoreIA5SubstringsIndexer( } } } - assert( i > 0 ); if( nkeys == 0 ) { /* no keys to generate */