X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Fcompare.c;h=4af59d01b8d15842a6a5f44db0244028d1a04c66;hb=70092b38fb23b9141a2b8414fb5a9c5200f3c12d;hp=dc7fc839c9075ae9fc52c96e63639056156de324;hpb=53ee6b01b97875b91abb5e1cdc28f93a8f1bbf21;p=openldap diff --git a/libraries/libldap/compare.c b/libraries/libldap/compare.c index dc7fc839c9..4af59d01b8 100644 --- a/libraries/libldap/compare.c +++ b/libraries/libldap/compare.c @@ -1,6 +1,6 @@ /* $OpenLDAP$ */ /* - * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file */ /* Portions @@ -36,7 +36,7 @@ * attr and value) are supplied. The msgid of the response is returned. * * Example: - * struct berval bvalue = { "secret", strlen("secret") }; + * struct berval bvalue = { "secret", sizeof("secret")-1 }; * rc = ldap_compare( ld, "c=us@cn=bob", * "userPassword", &bvalue, * sctrl, cctrl, &msgid ) @@ -51,9 +51,14 @@ ldap_compare_ext( LDAPControl **cctrls, int *msgidp ) { + int rc; BerElement *ber; +#ifdef NEW_LOGGING + LDAP_LOG (( "compare", LDAP_LEVEL_ENTRY, "ldap_compare\n" )); +#else Debug( LDAP_DEBUG_TRACE, "ldap_compare\n", 0, 0, 0 ); +#endif assert( ld != NULL ); assert( LDAP_VALID( ld ) ); @@ -61,12 +66,16 @@ ldap_compare_ext( assert( attr != NULL ); assert( msgidp != NULL ); + /* check client controls */ + rc = ldap_int_client_controls( ld, cctrls ); + if( rc != LDAP_SUCCESS ) return rc; + /* create a message to send */ if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) { return( LDAP_NO_MEMORY ); } - if ( ber_printf( ber, "{it{s{sO}}", /* '}' */ + if ( ber_printf( ber, "{it{s{sON}N}", /* '}' */ ++ld->ld_msgid, LDAP_REQ_COMPARE, dn, attr, bvalue ) == -1 ) { @@ -81,7 +90,7 @@ ldap_compare_ext( return ld->ld_errno; } - if( ber_printf( ber, /*{*/ "}" ) == -1 ) { + if( ber_printf( ber, /*{*/ "N}" ) == -1 ) { ld->ld_errno = LDAP_ENCODING_ERROR; ber_free( ber, 1 ); return( ld->ld_errno ); @@ -122,6 +131,8 @@ ldap_compare( int msgid; struct berval bvalue; + assert( value != NULL ); + bvalue.bv_val = (char *) value; bvalue.bv_len = (value == NULL) ? 0 : strlen( value ); @@ -162,6 +173,8 @@ ldap_compare_s( { struct berval bvalue; + assert( value != NULL ); + bvalue.bv_val = (char *) value; bvalue.bv_len = (value == NULL) ? 0 : strlen( value );