]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/compare.c
Don't pass NULL hostname to ldap_pvt_tls_check_hostname, use "localhost"
[openldap] / libraries / libldap / compare.c
index 489905b9703270097c505c523351b369563b5069..2b890b1fe9d7af4f47646f54b9bb5f93b162121c 100644 (file)
@@ -1,5 +1,6 @@
+/* $OpenLDAP$ */
 /*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 /*  Portions
@@ -9,6 +10,16 @@
  *  compare.c
  */
 
+/* The compare request looks like this:
+ *     CompareRequest ::= SEQUENCE {
+ *             entry   DistinguishedName,
+ *             ava     SEQUENCE {
+ *                     type    AttributeType,
+ *                     value   AttributeValue
+ *             }
+ *     }
+ */
+
 #include "portable.h"
 
 #include <stdio.h>
@@ -40,29 +51,29 @@ ldap_compare_ext(
        LDAPControl **cctrls,
        int     *msgidp )
 {
+       int rc;
        BerElement      *ber;
 
-       /* The compare request looks like this:
-        *      CompareRequest ::= SEQUENCE {
-        *              entry   DistinguishedName,
-        *              ava     SEQUENCE {
-        *                      type    AttributeType,
-        *                      value   AttributeValue
-        *              }
-        *      }
-        * and must be wrapped in an LDAPMessage.
-        */
-
        Debug( LDAP_DEBUG_TRACE, "ldap_compare\n", 0, 0, 0 );
 
+       assert( ld != NULL );
+       assert( LDAP_VALID( ld ) );
+       assert( dn != NULL );
+       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 )) == NULLBER ) {
+       if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
                return( LDAP_NO_MEMORY );
        }
 
-       if ( ber_printf( ber, "{it{s{sO}}", /* leave open '}' */
+       if ( ber_printf( ber, "{it{s{sON}N}", /* '}' */
                ++ld->ld_msgid,
-               LDAP_REQ_COMPARE, dn, attr, &bvalue ) == -1 )
+               LDAP_REQ_COMPARE, dn, attr, bvalue ) == -1 )
        {
                ld->ld_errno = LDAP_ENCODING_ERROR;
                ber_free( ber, 1 );
@@ -75,7 +86,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 );
@@ -160,4 +171,4 @@ ldap_compare_s(
        bvalue.bv_len = (value == NULL) ? 0 : strlen( value );
 
        return ldap_compare_ext_s( ld, dn, attr, &bvalue, NULL, NULL );
-}
\ No newline at end of file
+}