Ticket #47748 - Simultaneous adding a user and binding as the user could fail in the password policy check

Bug description: In do_bind, bind_target_entry is retrieved from the
DB or the entry cache.  There was a small window that the entry failed
to retrieve from there but the bind procedure in the backend (be_bind)
succeeds.  In the case, NULL bind_target_entry is passed to the Pass-
word Policy check and it fails.

Fix description: If be_bind returns SUCCESS and bind_target_entry is
NULL, retrieve bind_target_entry agian, which is guaranteed since the
entry was retrieved in the backend and placed in the entry cache.

https://fedorahosted.org/389/ticket/47748

Reviewed by rmeggins@redhat.com (Thank you, Rich!!)
(cherry picked from commit 4fc53e1a63222d0ff67c30a59f2cff4b535f90a8)
(cherry picked from commit f8f063c3fb2c7642506cbad923c71972f78edac2)
(cherry picked from commit feed9ba773766ade744ca4d45aca46c91d4b7f4f)
Ticket 47740 - Fix coverity issues(part 7)

12496 - resource leak - ldap/servers/slapd/mapping_tree.c
12497 - resource leak - ldap/servers/slapd/mapping_tree.c
12500 - resource leak - ldap/servers/plugins/chainingdb/cb_instance.c
12501 - resource leak - ldap/servers/plugins/sync/sync_refresh.c
12506 - resource leak - ldap/servers/plugins/chainingdb/cb_config.c
12509 - reosurce leak - ldap/servers/plugins/chainingdb/cb_bind.c
12510 - reosurce leak - lib/ldaputil/certmap.c
12538 - resource leak - ldap/servers/plugins/mep/mep.c
12539 - resource leak - ldap/servers/plugins/posix-winsync/posix-winsync.c
12540 - resource leak - ldap/servers/plugins/posix-winsync/posix-winsync.c
12541 - resource leak - ldap/servers/plugins/posix-winsync/posix-winsync.c
12542 - resource leak - ldap/servers/plugins/posix-winsync/posix-winsync.c

https://fedorahosted.org/389/ticket/47740

Reviewed by: nhosoi(Thanks!)
(cherry picked from commit 99609ceebad3bfb1926065ca4c0337847ccf38dd)
Ticket #47448 - Segfault in 389-ds-base-1.3.1.4-1.fc19 when setting up FreeIPA replication

https://fedorahosted.org/389/ticket/47448
Reviewed by: lkrispenz (Thanks!)
Branch: master
Fix Description: valueset_add_valueset() sets the values in the vs1
destination valueset.  It expects that vs1 is empty.  Particularly, the
sorted array.  If the source valueset vs2->sorted is NULL, it assumes
vs1->sorted is NULL already, and does not free it and set it to NULL.
The fix is to free both vs1->sorted and vs1->va.  NOTE: this fixes
the crash, but does not address the larger issue that the semantics of
valueset_add_valueset are not correct - valueset_add_valueset should add
the values from vs2 to vs1, rather than replace vs1 with vs2.
Also added post-condition assertions.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit df53a874436503ef99594fc09e3d817317f86940)

Backported from 389-ds-base-1.3.1 to 389-ds-base-1.2.11.
The patch was reviewed by rmeggins@redhat.com (Thank you, Rich!!)
NOTE: this patch is needed for Ticket #346 - Slow ldapmodify operation
time for large quantities of multi-valued attribute values
Ticket #47492 - PassSync removes User must change password flag on the Windows side

https://fedorahosted.org/389/ticket/47492
Reviewed by: nkinder (Thanks!)
Branch: 389-ds-base-1.2.11
Fix Description: Cherry pick broke outbound sync.  The suffix variable in
map_entry_dn_outbound was initialized to NULL and not set.  This patch
restores the previous functionality removed by the cherry pick.
NOTE: On 1.3.0 and later, the code has changed quite a bit, so that code
is not affected
Platforms tested: RHEL5 x86_64
Flag Day: no
Doc impact: no