]> git.sur5r.net Git - openldap/commitdiff
ITS#2684 fix bogus entry_free(), connection problem remains
authorHoward Chu <hyc@openldap.org>
Sun, 19 Oct 2003 04:42:02 +0000 (04:42 +0000)
committerHoward Chu <hyc@openldap.org>
Sun, 19 Oct 2003 04:42:02 +0000 (04:42 +0000)
servers/slapd/syncrepl.c

index 826f0c4bca3b8c5c3fc5d3f2a488d3a729f1a818..370d27d888f5f08d3f84793b0d2721a51222b8c8 100644 (file)
@@ -676,7 +676,7 @@ syncrepl_message_to_entry(
        char txtbuf[SLAP_TEXT_BUFLEN];
        size_t textlen = sizeof txtbuf;
 
-       struct berval   bdn = {0, NULL};
+       struct berval   bdn = {0, NULL}, dn, ndn;
        int             rc;
 
        ber_len_t       len;
@@ -707,7 +707,29 @@ syncrepl_message_to_entry(
                Debug( LDAP_DEBUG_ANY,
                        "syncrepl_message_to_entry : control get failed (%d)", rc, 0, 0 );
 #endif
-               goto done;
+               return NULL;
+       }
+
+       if ( rctrls ) {
+               BerElementBuffer berbuf;
+               BerElement      *ctrl_ber;
+
+               rctrlp = *rctrls;
+               ctrl_ber = (BerElement *)&berbuf;
+               ber_init2( ctrl_ber, &rctrlp->ldctl_value, LBER_USE_DER );
+               ber_scanf( ctrl_ber, "{eo", syncstate, syncUUID );
+               if ( ber_peek_tag( ctrl_ber, &len ) == LDAP_SYNC_TAG_COOKIE ) {
+                       ber_scanf( ctrl_ber, "o}", syncCookie );
+               }
+               ldap_controls_free( rctrls );
+       } else {
+#ifdef NEW_LOGGING
+               LDAP_LOG( OPERATION, ERR,"syncrepl_message_to_entry : "
+                       " rctrls absent\n", 0, 0, 0 );
+#else
+               Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_entry :"
+                       " rctrls absent\n", 0, 0, 0 );
+#endif
        }
 
        rc = ldap_get_dn_ber( ld, msg, &ber, &bdn );
@@ -723,12 +745,17 @@ syncrepl_message_to_entry(
                return NULL;
        }
 
+       dnPrettyNormal( NULL, &bdn, &dn, &ndn, op->o_tmpmemctx );
+       ber_dupbv( &op->o_req_dn, &dn );
+       ber_dupbv( &op->o_req_ndn, &ndn );
+       sl_free( ndn.bv_val, op->o_tmpmemctx );
+       sl_free( dn.bv_val, op->o_tmpmemctx );
+
+       if ( *syncstate == LDAP_SYNC_PRESENT || *syncstate == LDAP_SYNC_DELETE ) {
+               return NULL;
+       }
+
        e = ( Entry * ) ch_calloc( 1, sizeof( Entry ) );
-       dnPrettyNormal( NULL, &bdn, &e->e_name, &e->e_nname, op->o_tmpmemctx );
-       ber_dupbv( &op->o_req_dn, &e->e_name );
-       ber_dupbv( &op->o_req_ndn, &e->e_nname );
-       sl_free( e->e_nname.bv_val, op->o_tmpmemctx );
-       sl_free( e->e_name.bv_val, op->o_tmpmemctx );
        e->e_name = op->o_req_dn;
        e->e_nname = op->o_req_ndn;
 
@@ -749,33 +776,6 @@ syncrepl_message_to_entry(
                modtail = &mod->sml_next;
        }
 
-       if ( rctrls ) {
-               BerElementBuffer berbuf;
-               BerElement      *ctrl_ber;
-
-               rctrlp = *rctrls;
-               ctrl_ber = (BerElement *)&berbuf;
-               ber_init2( ctrl_ber, &rctrlp->ldctl_value, LBER_USE_DER );
-               ber_scanf( ctrl_ber, "{eo", syncstate, syncUUID );
-               if ( ber_peek_tag( ctrl_ber, &len ) == LDAP_SYNC_TAG_COOKIE ) {
-                       ber_scanf( ctrl_ber, "o}", syncCookie );
-               }
-               ldap_controls_free( rctrls );
-       } else {
-#ifdef NEW_LOGGING
-               LDAP_LOG( OPERATION, ERR,"syncrepl_message_to_entry : "
-                       " rctrls absent\n", 0, 0, 0 );
-#else
-               Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_entry :"
-                       " rctrls absent\n", 0, 0, 0 );
-#endif
-       }
-
-       if ( *syncstate == LDAP_SYNC_PRESENT || *syncstate == LDAP_SYNC_DELETE ) {
-               rc = 1;
-               goto done;
-       }
-
        if ( *modlist == NULL ) {
 #ifdef NEW_LOGGING
                LDAP_LOG( OPERATION, ERR,
@@ -991,7 +991,7 @@ syncrepl_entry(
                        rc = be->be_delete( op, &rs );
                }
                /* Already deleted otherwise */
-               return 1;
+               return 0;
 
        default :
 #ifdef NEW_LOGGING