[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: one-level search error? (ITS#1654)



Kurt@OpenLDAP.org wrote:
> 
> At 01:26 AM 2002-03-25, Pierangelo Masarati wrote:
> >I have a quick fix for this problem, there's a possibly unneeded call
> >to dn_normalize() in back-ldbm/search.c:286 of REL_ENG_2 code:
> >
> >        /* check scope */
> >        if ( !scopeok && scope == LDAP_SCOPE_ONELEVEL ) {
> >                if ( (dn = dn_parent( be, e->e_ndn )) != NULL ) {
> >-                       (void) dn_normalize( dn );
> >                        scopeok = (dn == realbase)
> >                                ? 1
> >                                : (strcmp( dn, realbase ) ? 0 : 1 );
> >                        free( dn );
> >
> >                } else {
> >                        scopeok = (realbase == NULL || *realbase == '\0');
> >                }
> >
> >        } else if ( !scopeok && scope == LDAP_SCOPE_SUBTREE ) {
> >
> >
> >that causes the normalized twice portion of the entry's DN to differ from the
> >normalized once searchbase.  Of course the real bug is in the
> >dn_normalize()/dn_validate() code, but I'm sure we don't want to go back
> >to those functions and fix their logic.
> >
> >What seems to happen is that when a sequence of '\' is present, only the
> >first couple gets escaped (e.g. '\\\\' becomes '\\\' instead of '\\').
> >
> >Note that this doesn't affect the fact that normalizing things more
> >than once leads to erroneous results: '\\\\' => '\\' => '\' even if the
> >logic of dn_normalize() is ok.
> >
> >I don't remember why that second normalization appeared in that portion
> >of code, so I'm not sure whether it's safe to take it away.
> 
> It likely was added to deal with spaces after the separator.

Sure.  Then we could replace 

	(void) dn_normalize( dn );

with

	while ( isspace( dn[ 0 ] ) ) dn++;

I'm afraid this is one of the reasons we completely reworked the
dn handling :)

Ando.

-- 
Dr. Pierangelo Masarati               | voice: +39 02 2399 8309
Dip. Ing. Aerospaziale                | fax:   +39 02 2399 8334
Politecnico di Milano                 |
mailto:pierangelo.masarati@polimi.it
via La Masa 34, 20156 Milano, Italy   |
http://www.aero.polimi.it/~masarati