From: Howard Chu Date: Sun, 19 Oct 2003 04:42:02 +0000 (+0000) Subject: ITS#2684 fix bogus entry_free(), connection problem remains X-Git-Tag: OPENLDAP_REL_ENG_2_1_MP~541 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b144ca2169e5f8c65dc96417f52909c7bf792938;p=openldap ITS#2684 fix bogus entry_free(), connection problem remains --- diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 826f0c4bca..370d27d888 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -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