]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#10450 slapd controls.c: cleanup parseAssert / parseValuesReturnFilter
authorHoward Chu <hyc@openldap.org>
Fri, 6 Feb 2026 16:44:38 +0000 (16:44 +0000)
committerHoward Chu <hyc@openldap.org>
Fri, 6 Feb 2026 16:44:38 +0000 (16:44 +0000)
Delete improper error handling, avoid unnecessary debug activity

servers/slapd/controls.c

index 4cc22cfe357237f241018f412c4f92877ff31957..bd70aa02bc6c1e9f84c722511618f8f4edbbb1d8 100644 (file)
@@ -1424,7 +1424,6 @@ static int parseAssert (
        LDAPControl *ctrl )
 {
        BerElement      *ber;
-       struct berval   fstr = BER_BVNULL;
 
        if ( op->o_assert != SLAP_CONTROL_NONE ) {
                rs->sr_text = "assert control specified multiple times";
@@ -1451,26 +1450,18 @@ static int parseAssert (
                &rs->sr_text);
        (void) ber_free( ber, 1 );
        if( rs->sr_err != LDAP_SUCCESS ) {
-               if( rs->sr_err == SLAPD_DISCONNECT ) {
-                       rs->sr_err = LDAP_PROTOCOL_ERROR;
-                       send_ldap_disconnect( op, rs );
-                       rs->sr_err = SLAPD_DISCONNECT;
-               } else {
-                       send_ldap_result( op, rs );
-               }
-               if( op->o_assertion != NULL ) {
-                       filter_free_x( op, op->o_assertion, 1 );
-                       op->o_assertion = NULL;
-               }
                return rs->sr_err;
        }
 
 #ifdef LDAP_DEBUG
-       filter2bv_x( op, op->o_assertion, &fstr );
+       if ( LogTest( LDAP_DEBUG_ARGS )) {
+               struct berval   fstr = BER_BVNULL;
+               filter2bv_x( op, op->o_assertion, &fstr );
 
-       Debug( LDAP_DEBUG_ARGS, "parseAssert: conn %ld assert: %s\n",
-               op->o_connid, fstr.bv_len ? fstr.bv_val : "empty" );
-       op->o_tmpfree( fstr.bv_val, op->o_tmpmemctx );
+               Debug( LDAP_DEBUG_ARGS, "parseAssert: conn %ld assert: %s\n",
+                       op->o_connid, fstr.bv_len ? fstr.bv_val : "empty" );
+               op->o_tmpfree( fstr.bv_val, op->o_tmpmemctx );
+       }
 #endif
 
        op->o_assert = ctrl->ldctl_iscritical
@@ -1608,7 +1599,6 @@ static int parseValuesReturnFilter (
        LDAPControl *ctrl )
 {
        BerElement      *ber;
-       struct berval   fstr = BER_BVNULL;
 
        if ( op->o_valuesreturnfilter != SLAP_CONTROL_NONE ) {
                rs->sr_text = "valuesReturnFilter control specified multiple times";
@@ -1637,26 +1627,18 @@ static int parseValuesReturnFilter (
        (void) ber_free( ber, 1 );
 
        if( rs->sr_err != LDAP_SUCCESS ) {
-               if( rs->sr_err == SLAPD_DISCONNECT ) {
-                       rs->sr_err = LDAP_PROTOCOL_ERROR;
-                       send_ldap_disconnect( op, rs );
-                       rs->sr_err = SLAPD_DISCONNECT;
-               } else {
-                       send_ldap_result( op, rs );
-               }
-               if( op->o_vrFilter != NULL) {
-                       vrFilter_free( op, op->o_vrFilter );
-                       op->o_vrFilter = NULL;
-               }
+               return rs->sr_err;
        }
+
 #ifdef LDAP_DEBUG
-       else {
+       if ( LogTest( LDAP_DEBUG_ARGS )) {
+               struct berval   fstr = BER_BVNULL;
                vrFilter2bv( op, op->o_vrFilter, &fstr );
-       }
 
-       Debug( LDAP_DEBUG_ARGS, "       vrFilter: %s\n",
-               fstr.bv_len ? fstr.bv_val : "empty" );
-       op->o_tmpfree( fstr.bv_val, op->o_tmpmemctx );
+               Debug( LDAP_DEBUG_ARGS, "       vrFilter: %s\n",
+                       fstr.bv_len ? fstr.bv_val : "empty" );
+               op->o_tmpfree( fstr.bv_val, op->o_tmpmemctx );
+       }
 #endif
 
        op->o_valuesreturnfilter = ctrl->ldctl_iscritical