]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
Fix issues in bind response handling
authorOndřej Kuzník <ondra@mistotebe.net>
Fri, 23 Jun 2017 10:07:59 +0000 (11:07 +0100)
committerOndřej Kuzník <okuznik@symas.com>
Tue, 17 Nov 2020 17:55:46 +0000 (17:55 +0000)
servers/lloadd/upstream.c

index 8485afe658b706435bd7ca8988af9345fa0fb11f..3b00ca5446b1251926143ad4ddc4c6698fa1b157 100644 (file)
@@ -87,18 +87,23 @@ static int
 handle_bind_response( Operation *op, BerElement *ber )
 {
     Connection *c = op->o_client;
+    BerValue response;
     BerElement *copy;
-    ber_int_t msgid, result;
+    ber_int_t result;
     ber_tag_t tag;
-    int rc = 0;
+    int rc = LDAP_SUCCESS;
 
-    copy = ber_dup( ber );
-    if ( !copy ) {
+    if ( (copy = ber_alloc()) == NULL ) {
         rc = -1;
         goto done;
     }
 
-    tag = ber_scanf( copy, "{i{e" /* "}}" */, &msgid, &result );
+    tag = ber_peek_element( ber, &response );
+    assert( tag == LDAP_RES_BIND );
+
+    ber_init2( copy, &response, 0 );
+
+    tag = ber_get_enum( copy, &result );
     ber_free( copy, 0 );
 
     if ( tag == LBER_ERROR ) {
@@ -132,16 +137,15 @@ handle_bind_response( Operation *op, BerElement *ber )
             break;
         }
     }
+    CONNECTION_UNLOCK(c);
 
 done:
     if ( rc ) {
-        operation_destroy_from_client( op );
-        CONNECTION_UNLOCK(c);
+        operation_send_reject( op, LDAP_OTHER, "internal error", 0 );
 
         ber_free( ber, 1 );
-        return rc;
+        return LDAP_SUCCESS;
     }
-    CONNECTION_UNLOCK(c);
     return forward_final_response( op, ber );
 }