From 85621c882a23d2ca120d762121d99952dd020c45 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Tue, 8 Dec 2009 20:53:39 +0000 Subject: [PATCH] guard against simultaneous REP_ENTRY_MUSTRELEASE and REP_ENTRY_MODIFIABLE (related to ITS#6423) --- servers/slapd/overlays/collect.c | 16 ++++++++++++---- servers/slapd/overlays/valsort.c | 16 +++++++++++++--- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/servers/slapd/overlays/collect.c b/servers/slapd/overlays/collect.c index 3e5ee67db3..90867fdc8b 100644 --- a/servers/slapd/overlays/collect.c +++ b/servers/slapd/overlays/collect.c @@ -386,10 +386,18 @@ collect_response( Operation *op, SlapReply *rs ) * don't modify it directly. Make a copy and * work with that instead. */ - if ( !( rs->sr_flags & REP_ENTRY_MODIFIABLE )) { - rs->sr_entry = entry_dup( rs->sr_entry ); - rs->sr_flags |= REP_ENTRY_MODIFIABLE | - REP_ENTRY_MUSTBEFREED; + if ( !( rs->sr_flags & REP_ENTRY_MODIFIABLE ) ) { + Entry *e; + + e = entry_dup( rs->sr_entry ); + if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) { + overlay_entry_release_ov( op, rs->sr_entry, 0, on ); + rs->sr_flags &= ~REP_ENTRY_MUSTRELEASE; + } else if ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) { + entry_free( rs->sr_entry ); + } + rs->sr_entry = e; + rs->sr_flags |= REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED; } /* Loop for each attribute in this collectinfo */ diff --git a/servers/slapd/overlays/valsort.c b/servers/slapd/overlays/valsort.c index c5716eee3e..53a2e91925 100644 --- a/servers/slapd/overlays/valsort.c +++ b/servers/slapd/overlays/valsort.c @@ -297,9 +297,19 @@ valsort_response( Operation *op, SlapReply *rs ) a = attr_find( rs->sr_entry->e_attrs, vi->vi_ad ); if ( !a ) continue; - if (( rs->sr_flags & ( REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED )) != - ( REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED )) { - rs->sr_entry = entry_dup( rs->sr_entry ); + if (( rs->sr_flags & ( REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED ) ) != + ( REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED ) ) + { + Entry *e; + + e = entry_dup( rs->sr_entry ); + if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) { + overlay_entry_release_ov( op, rs->sr_entry, 0, on ); + rs->sr_flags &= ~REP_ENTRY_MUSTRELEASE; + } else if ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) { + entry_free( rs->sr_entry ); + } + rs->sr_entry = e; rs->sr_flags |= REP_ENTRY_MODIFIABLE|REP_ENTRY_MUSTBEFREED; a = attr_find( rs->sr_entry->e_attrs, vi->vi_ad ); } -- 2.39.5