From c0e3958cefa412a5c2348c645957719c4c4622e9 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Fri, 7 Oct 2005 18:53:34 +0000 Subject: [PATCH] Fixed slapd req_pwdexop bug Fixed slapo-syncprov queued UUIDs bug (ITS#4068) Fixed slapo-syncprov memory leak Fixed slapd anlist leak Removed lint Build Environment Updated testsuite to test only primary backends by default Disable test041-aci --- CHANGES | 6 ++++++ servers/slapd/ad.c | 13 +++++++------ servers/slapd/daemon.c | 2 +- servers/slapd/ldapsync.c | 3 ++- servers/slapd/overlays/syncprov.c | 14 +++++++++----- servers/slapd/passwd.c | 2 ++ servers/slapd/slap.h | 3 +-- servers/slapd/syncrepl.c | 6 ++---- tests/Makefile.in | 4 ++++ 9 files changed, 34 insertions(+), 19 deletions(-) diff --git a/CHANGES b/CHANGES index ac2aae4f48..8e3f678941 100644 --- a/CHANGES +++ b/CHANGES @@ -1,7 +1,13 @@ OpenLDAP 2.3 Change Log OpenLDAP 2.3.9 Engineering + Fixed slapd req_pwdexop bug + Fixed slapo-syncprov queued UUIDs bug (ITS#4068) + Fixed slapo-syncprov memory leak + Fixed slapd anlist leak + Removed lint Build Environment + Updated testsuite to test only primary backends by default Disable test041-aci OpenLDAP 2.3.8 Release diff --git a/servers/slapd/ad.c b/servers/slapd/ad.c index 676cf8d86f..d351c5c49d 100644 --- a/servers/slapd/ad.c +++ b/servers/slapd/ad.c @@ -988,8 +988,9 @@ anlist2attrs( AttributeName * anlist ) char **attrs; ObjectClass *oc; - attrs = anlist2charray( anlist, 1 ); - + if ( anlist == NULL ) + return NULL; + for ( i = 0; anlist[i].an_name.bv_val; i++ ) { if ( ( oc = anlist[i].an_oc ) ) { for ( j = 0; oc->soc_required && oc->soc_required[j]; j++ ) ; @@ -1002,6 +1003,8 @@ anlist2attrs( AttributeName * anlist ) if ( i == 0 ) return NULL; + attrs = anlist2charray( anlist, 1 ); + n = i; if ( k ) @@ -1026,9 +1029,8 @@ anlist2attrs( AttributeName * anlist ) i = 0; while ( attrs && attrs[i] ) { if ( *attrs[i] == '@' ) { + ch_free( attrs[i] ); for ( j = i; attrs[j]; j++ ) { - if ( j == i ) - ch_free( attrs[i] ); attrs[j] = attrs[j+1]; } } else { @@ -1040,9 +1042,8 @@ anlist2attrs( AttributeName * anlist ) j = i + 1; while ( attrs && attrs[j] ) { if ( !strcmp( attrs[i], attrs[j] )) { + ch_free( attrs[j] ); for ( k = j; attrs && attrs[k]; k++ ) { - if ( k == j ) - ch_free( attrs[j] ); attrs[k] = attrs[k+1]; } } else { diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index a0125a19fc..098bce5242 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -207,7 +207,7 @@ static struct slap_daemon { #define SLAP_SOCK_IS_MUTE(s) (!SLAP_SOCK_IS_READ(s)) #define SLAP_SOCK_SET_INIT \ - slap_daemon.sd_epolls = ch_malloc(sizeof(struct epoll_event) * dtblsize * 2); \ + slap_daemon.sd_epolls = ch_calloc(1, sizeof(struct epoll_event) * dtblsize * 2); \ slap_daemon.sd_index = ch_malloc(sizeof(int) * dtblsize); \ slap_daemon.sd_epfd = epoll_create( dtblsize ); \ for (i=0; ibv_val, rid ); } } - ber_str2bv( cookiestr, strlen(cookiestr), 1, cookie ); + ber_str2bv_x( cookiestr, strlen(cookiestr), 1, cookie, + op ? op->o_tmpmemctx : NULL ); } void diff --git a/servers/slapd/overlays/syncprov.c b/servers/slapd/overlays/syncprov.c index 4316dd042d..5c0b7cf4ef 100644 --- a/servers/slapd/overlays/syncprov.c +++ b/servers/slapd/overlays/syncprov.c @@ -749,6 +749,7 @@ syncprov_sendresp( Operation *op, opcookie *opc, syncops *so, Entry **e, int mod a_uuid.a_nvals = &opc->suuid; rs.sr_err = syncprov_state_ctrl( op, &rs, &e_uuid, mode, ctrls, 0, 1, &cookie ); + op->o_tmpfree( cookie.bv_val, op->o_tmpmemctx ); rs.sr_ctrls = ctrls; op->o_bd->bd_info = (BackendInfo *)on->on_info; @@ -910,13 +911,14 @@ syncprov_qresp( opcookie *opc, syncops *so, int mode ) sr->s_dn.bv_len = opc->sdn.bv_len; sr->s_mode = mode; sr->s_isreference = opc->sreference; - sr->s_ndn.bv_val = lutil_strcopy( sr->s_dn.bv_val, opc->sdn.bv_val ); + sr->s_ndn.bv_val = lutil_strcopy( sr->s_dn.bv_val, + opc->sdn.bv_val ) + 1; sr->s_ndn.bv_len = opc->sndn.bv_len; - *(sr->s_ndn.bv_val++) = '\0'; - sr->s_uuid.bv_val = lutil_strcopy( sr->s_ndn.bv_val, opc->sndn.bv_val ); + sr->s_uuid.bv_val = lutil_strcopy( sr->s_ndn.bv_val, + opc->sndn.bv_val ) + 1; sr->s_uuid.bv_len = opc->suuid.bv_len; - *(sr->s_uuid.bv_val++) = '\0'; - sr->s_csn.bv_val = lutil_strcopy( sr->s_uuid.bv_val, opc->suuid.bv_val ); + AC_MEMCPY( sr->s_uuid.bv_val, opc->suuid.bv_val, opc->suuid.bv_len ); + sr->s_csn.bv_val = sr->s_uuid.bv_val + sr->s_uuid.bv_len + 1; sr->s_csn.bv_len = opc->sctxcsn.bv_len; strcpy( sr->s_csn.bv_val, opc->sctxcsn.bv_val ); @@ -1810,11 +1812,13 @@ syncprov_search_response( Operation *op, SlapReply *rs ) rs->sr_err = syncprov_done_ctrl( op, rs, rs->sr_ctrls, 0, 1, &cookie, ss->ss_present ? LDAP_SYNC_REFRESH_PRESENTS : LDAP_SYNC_REFRESH_DELETES ); + op->o_tmpfree( cookie.bv_val, op->o_tmpmemctx ); } else { /* It's RefreshAndPersist, transition to Persist phase */ syncprov_sendinfo( op, rs, ( ss->ss_present && rs->sr_nentries ) ? LDAP_TAG_SYNC_REFRESH_PRESENT : LDAP_TAG_SYNC_REFRESH_DELETE, &cookie, 1, NULL, 0 ); + op->o_tmpfree( cookie.bv_val, op->o_tmpmemctx ); /* Detach this Op from frontend control */ ldap_pvt_thread_mutex_lock( &ss->ss_so->s_mutex ); diff --git a/servers/slapd/passwd.c b/servers/slapd/passwd.c index c8f8ce75b5..4c69a2e6b5 100644 --- a/servers/slapd/passwd.c +++ b/servers/slapd/passwd.c @@ -68,7 +68,9 @@ int passwd_extop( return LDAP_STRONG_AUTH_REQUIRED; } + qpw->rs_old.bv_len = 0; qpw->rs_old.bv_val = NULL; + qpw->rs_new.bv_len = 0; qpw->rs_new.bv_val = NULL; qpw->rs_mods = NULL; qpw->rs_modtail = NULL; diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 0d4a7fb983..0a628f79be 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1948,8 +1948,7 @@ typedef struct req_extended_s { } req_extended_s; typedef struct req_pwdexop_s { - struct berval rs_reqoid; - int rs_flags; + struct req_extended_s rs_extended; struct berval rs_old; struct berval rs_new; Modifications *rs_mods; diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 2a4220be9a..f812d5d4aa 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -231,9 +231,8 @@ init_syncrepl(syncinfo_t *si) j = 0; while ( exattrs[j] != NULL ) { if ( !strcmp( exattrs[j], sync_descs[i]->ad_cname.bv_val )) { + ch_free( exattrs[j] ); for ( k = j; exattrs[k] != NULL; k++ ) { - if ( k == j ) - ch_free( exattrs[k] ); exattrs[k] = exattrs[k+1]; } } else { @@ -250,9 +249,8 @@ init_syncrepl(syncinfo_t *si) while ( oc->soc_required[k] ) { if ( !strcmp( exattrs[i], oc->soc_required[k]->sat_cname.bv_val )) { + ch_free( exattrs[i] ); for ( l = i; exattrs[l]; l++ ) { - if ( l == i ) - ch_free( exattrs[i] ); exattrs[l] = exattrs[l+1]; } } else { diff --git a/tests/Makefile.in b/tests/Makefile.in index 2726162a01..32d2a5d6ff 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -21,9 +21,13 @@ BUILD_HDB=@BUILD_HDB@ BUILD_LDBM=@BUILD_LDBM@ BUILD_SQL=@BUILD_SQL@ +# test primary backends (default) test tests: @$(MAKE) bdb @$(MAKE) hdb + +# test all backends +alltests: tests @$(MAKE) ldbm @$(MAKE) sql -- 2.39.5