]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/extended.c
Fix ldap_rename parameter order (ITS#387)
[openldap] / libraries / libldap / extended.c
index 4f3f464562fefe8bc7ef1c92b5487af0c8d327cf..c3b382d18d9dfd45d5a8f9ebb2e75e16ed2764a7 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
@@ -40,6 +41,7 @@ ldap_extended_operation(
        int                             *msgidp )
 {
        BerElement *ber;
+       int rc;
 
        Debug( LDAP_DEBUG_TRACE, "ldap_extended_operation\n", 0, 0, 0 );
 
@@ -65,10 +67,19 @@ ldap_extended_operation(
                return( ld->ld_errno );
        }
 
-       if ( ber_printf( ber, "{it{tstO}", /* '}' */
-               ++ld->ld_msgid, LDAP_REQ_EXTENDED, LDAP_TAG_EXOP_REQ_OID,
-                       reqoid, LDAP_TAG_EXOP_REQ_VALUE, reqdata ) == -1 )
-       {
+       if ( reqdata != NULL ) {
+               rc = ber_printf( ber, "{it{tstO}", /* '}' */
+                       ++ld->ld_msgid, LDAP_REQ_EXTENDED,
+                       LDAP_TAG_EXOP_REQ_OID, reqoid,
+                       LDAP_TAG_EXOP_REQ_VALUE, reqdata );
+
+       } else {
+               rc = ber_printf( ber, "{it{ts}", /* '}' */
+                       ++ld->ld_msgid, LDAP_REQ_EXTENDED,
+                       LDAP_TAG_EXOP_REQ_OID, reqoid );
+       }
+
+       if( rc == -1 ) {
                ld->ld_errno = LDAP_ENCODING_ERROR;
                ber_free( ber, 1 );
                return( ld->ld_errno );
@@ -170,7 +181,7 @@ ldap_parse_extended_result (
                return ld->ld_errno;
        }
 
-       if( res->lm_msgtype == LDAP_RES_EXTENDED ) {
+       if( res->lm_msgtype != LDAP_RES_EXTENDED ) {
                ld->ld_errno = LDAP_PARAM_ERROR;
                return ld->ld_errno;
        }