Issue 636 - indexing can return NULL list
Summary: indexing can return NULL list
Status: VERIFIED FIXED
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: slapd (show other issues)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2000-07-24 00:01 UTC by Mark Adamson
Modified: 2014-08-01 21:05 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Mark Adamson 2000-07-24 00:01:30 UTC
I was loading a big feed into my 2.0 Beta slapd when the the server core
dumped. It was in the LDBM backend indexer() function in index.c. It had
called the substring indexer function, and was about to run key_change()
on the returned array of keys. The keys pointer was NULL, causing a
segmentation fault.


The indexer() function calls the substring indexer function for
whatever attribute it's working on, which is supposed to return an array
of keys in the last parameter. In this case, the indexer function was 
  caseIgnoreIA5SubstringsMatch()  in  servers/slapd/schema_init.c


If that substring matcher function finds that all of the values to index 
are too short to do a substring match, it points the array pointer to NULL
and returns LDAP_SUCCESS (see around line 1384, schema_init.c). The
indexer() function checks the return code, not the array pointer.  It sees
success, and then runs a for() loop on the keys, resulting in a SIGSEGV.

The indexer() function should check that the return code is LDAP_SUCCESS,
AND check if keys is non-NULL.   Another possible fix is for the substring
matcher function to NOT return SUCCESS if no values are indexable,
although non-success returns may trigger unhappiness in some other calling
functions.

I appended a patch for servers/slapd/back-ldbm/index.c

  -Mark Adamson
   Carnegie Mellon




--- .old/index.c        Tue Jun  6 13:43:21 2000
+++ index.c     Sun Jul 23 19:37:19 2000
@@ -174,7 +174,7 @@
                        ad->ad_type->sat_equality,
                        &prefix, vals, &keys );
 
-               if( rc == LDAP_SUCCESS ) {
+               if(( rc == LDAP_SUCCESS ) && ( keys != NULL)){
                        for( i= 0; keys[i] != NULL; i++ ) {
                                key_change( be, db, keys[i], id, op );
                        }
@@ -188,7 +188,7 @@
                        ad->ad_type->sat_approx,
                        &prefix, vals, &keys );
 
-               if( rc == LDAP_SUCCESS ) {
+               if(( rc == LDAP_SUCCESS ) && ( keys != NULL)){
                        for( i= 0; keys[i] != NULL; i++ ) {
                                key_change( be, db, keys[i], id, op );
                        }
@@ -202,7 +202,7 @@
                        ad->ad_type->sat_substr,
                        &prefix, vals, &keys );
 
-               if( rc == LDAP_SUCCESS ) {
+               if(( rc == LDAP_SUCCESS ) && ( keys != NULL)){
                        for( i= 0; keys[i] != NULL; i++ ) {
                                key_change( be, db, keys[i], id, op );
                        }


Comment 1 Kurt Zeilenga 2000-07-24 16:15:00 UTC
moved from Incoming to Development
Comment 2 Kurt Zeilenga 2000-07-24 16:25:21 UTC
applied, please test, thanks

Kurt
Comment 3 Kurt Zeilenga 2000-07-24 16:25:36 UTC
changed state Open to Test
Comment 4 Kurt Zeilenga 2000-07-26 14:38:35 UTC
changed notes
changed state Test to Closed
Comment 5 OpenLDAP project 2014-08-01 21:05:27 UTC
fixed