From: Julio Sánchez Fernández Date: Sun, 15 Oct 2000 19:17:06 +0000 (+0000) Subject: Better processing of extensible filters. Needs testing, but the prior X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1737 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5d899f0c00277dcc111b715e750505e836adaea1;p=openldap Better processing of extensible filters. Needs testing, but the prior version was not encoding properly the filter. --- diff --git a/libraries/libldap/search.c b/libraries/libldap/search.c index ceeb779ab2..4f028b0b1e 100644 --- a/libraries/libldap/search.c +++ b/libraries/libldap/search.c @@ -753,38 +753,39 @@ put_simple_filter( if( dn == NULL ) { if(! ldap_is_attr_desc( str ) ) goto done; - break; - } + } else { - *dn++ = '\0'; - rule = strchr( dn, ':' ); + *dn++ = '\0'; + rule = strchr( dn, ':' ); - if( rule == NULL ) { - /* one colon */ - if ( strcmp(dn, "dn") == 0 ) { - /* must have attribute */ - if( !ldap_is_attr_desc( str ) ) { - goto done; - } + if( rule == NULL ) { + /* one colon */ + if ( strcmp(dn, "dn") == 0 ) { + /* must have attribute */ + if( !ldap_is_attr_desc( str ) ) { + goto done; + } - rule = ""; + rule = ""; - } else { - rule = dn; - dn = NULL; - } + } else { + rule = dn; + dn = NULL; + } - } else { - /* two colons */ - *rule++ = '\0'; + } else { + /* two colons */ + *rule++ = '\0'; - if ( strcmp(dn, "dn") != 0 ) { - /* must have "dn" */ - goto done; + if ( strcmp(dn, "dn") != 0 ) { + /* must have "dn" */ + goto done; + } } + } - if ( *str == '\0' && *rule == '\0' ) { + if ( *str == '\0' && ( !rule || *rule == '\0' ) ) { /* must have either type or rule */ goto done; } @@ -793,13 +794,13 @@ put_simple_filter( goto done; } - if ( *rule != '\0' && !ldap_is_attr_oid( rule ) ) { + if ( rule && *rule != '\0' && !ldap_is_attr_oid( rule ) ) { goto done; } rc = ber_printf( ber, "t{" /*}*/, ftype ); - if( rc != -1 && *rule != '\0' ) { + if( rc != -1 && rule && *rule != '\0' ) { rc = ber_printf( ber, "ts", LDAP_FILTER_EXT_OID, rule ); } if( rc != -1 && *str != '\0' ) { @@ -818,7 +819,7 @@ put_simple_filter( } } } - break; + goto done; default: if ( ldap_pvt_find_wildcard( value ) == NULL ) {