Full_Name: Patrick Timmons Version: 1.2.1 OS: AIX 4.2 URL: ftp://ftp.openldap.org/incoming/ Submission from: (NULL) (132.207.22.40) DN that contains spaces between parts are not entered correctly in the dn index for ldbm databases. For example, 'dn: cn=Patrick Timmons,ou=personnel,o=polymtl.ca' will be entered correctly but 'dn: cn=Patrick timmons, ou=personnel, o=polymtl.ca' will not. A search like 'ldapsearch -b "ou=personnel,o=polymtl.ca" "uid=*" dn uid' will not find anything when in fact it should return all records in the ou=personnel branch. This is caused by an error in the calculation of the lenght of the value to enter in the dn index when there is/are space/s between parts. In file servers/slapd/back-ldbm/index.c subroutine index_add_values(), the lenght of the value to index is computed before the call to subroutine value_normalize(). If the normalization process removes spaces from the value, the length will change. Since the lenght is not recomputed after the call to value_normalize(), values with spaces between items will not be entered in the index file correctly. Example: dn: cn=Patrick Timmons, ou=personnel, o=polymtl.ca with a lenght of 46 characters for cn=Patr ... polymtl.ca will be normalized to: dn:cn=PATRICK TIMMONS,ou=PERSONNEL,o=POLYMTL.CA which is 2 characters less than unnormalized. The code to create the substring index looks like this: create entry for '*'+'^'+<first two characters> // string must start with 'cn' create entry for '*'+<last two characters>+'$' // string must end with 'CA' for each 3 letter substrings create entry for '*'+substring The <last two characters>'s position is obtained from the lenght computed before normalization: p = val + len - SUBLEN + 1; In the case of the previous example it gives: p = Address_of_var_val + 46 - 3 + 1 == Address_of_var_val + 44 which is good because we need val[44]+val[45]+'$' but after normalization, the value has only 44 characters ([0..43], val[44]=='\0') and subroutine add_value() will be asked to create an index value for '*'+'\0'+?+'$'+'\0' instead of '*'+'C'+'A'+'$'+'\0'. If you change the code to recompute the lenght after the call to value_normalize(), the index is created correctly. I uploaded a patch to ftp.openldap.org as patrick-timmons-990601.patch PT.
Thanks. I've just committed a fix to -devel and OPENLDAP_REL_ENG_1_2. Please test the below patch (against 1.2.2). http://www.openldap.org/devel/cvsweb.cgi/servers/slapd/back-ldbm/index.c.diff?r1=1.5.2.5.2.6&r2=1.5.2.5.2.7 Note: Changes are generally available on cvs.openldap.org (and CVSweb) within 30 minutes of being committed.
changed notes changed state Open to Test moved from Incoming to Software Bugs
As Patrick pointed out to me, index_add_values() still needs to recompute the length of val value_normalize() may change it. I've added Patrick's suggested fix for the time being. (value_normalize should be modified to take struct berval * instead of a char* len). Please review and test: http://www.openldap.org/devel/cvsweb.cgi/servers/slapd/back-ldbm/index.c.diff?r1=1.5.2.5.2.6&r2=1.5.2.5.2.8 ( a similiar change has been applied to -devel as well ).
changed notes changed state Test to Closed
Released patch w/ 1.2.3