Ticket #47773 - mem leak in do_bind when there is an error

https://fedorahosted.org/389/ticket/47773
Reviewed by: nhosoi (Thanks!)
Branch: 389-ds-base-1.3.2
Fix Description: Do not get the SLAPI_BIND_TARGET_SDN from the pblock and
free it in the clean up code if it was never set in the pblock - just free
the local variable sdn in this case.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 2a57b521b86b24c0f0a8ddfbea4169c71ee4e896)
Ticket #47774 mem leak in do_search - rawbase not freed upon certain errors

https://fedorahosted.org/389/ticket/47774
Reviewed by: nhosoi (Thanks!)
Branch: 389-ds-base-1.3.2
Fix Description: Free the local rawbase variable if it was not set in the
pblock.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 1d5c6d6ca300a45305dba631a334ae9a1857d4cb)
Ticket #47772 empty modify returns LDAP_INVALID_DN_SYNTAX

https://fedorahosted.org/389/ticket/47772
Reviewed by: mreynolds (Thanks!)
Branch: 389-ds-base-1.3.2
Fix Description: Do not call normalize_mods2bvals if mods is NULL - just allow
the empty modify op to proceed.  Since normalize_mods2bvals only cares about
DN syntax attributes, it is appropriate to return LDAP_INVALID_DN_SYNTAX if
normalize_mods2bvals returns NULL.
Since this fix allows NULL mods to proceed throughout the code, I checked for
all places that SLAPI_MODIFY_MODS was used, to make sure we don't try to
dereference NULL mods, and to make sure the NULL mods were handled correctly
otherwise.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry-picked with conflicts from f5730129dfbc4ef3808735051b12cbfda518f4fb)
Ticket #47772 empty modify returns LDAP_INVALID_DN_SYNTAX

https://fedorahosted.org/389/ticket/47772
Reviewed by: tbordaz, mreynolds (Thanks!)
Branch: 389-ds-base-1.3.2
Fix Description: tbordaz pointed out a couple of other places where the
pblock modify_mods structure is being referenced directly, and needs to be
checked for NULL.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
Ticket 47782 - Parent numbordinate count can be incorrectly updated if an error occurs

Bug Description:  When adding and deleting entries there is a small chance that the modified
                  parent entry(numbsubordinates) could be replaced in the entry cache, even
                  if the operation fails.

Fix Description:  For deletes we can simply move the cache entry switching to a safe location,
                  but for adds we need to unswitch the parent's entry in the cache.

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

Reviewed by: nhosoi(Thanks!)
(cherry picked from commit 2079892800843d1541a8f712d0b1395f75919ee9)
Ticket #346 - Slow ldapmodify operation time for large quantities of multi-valued attribute values

Description: slapi_entry_add_value is used to add values for sorting,
which did not pass the attribute syntax info and the fallback compare
algorithm was used.  It sometimes different from the attribute syntax
based sorting and failed to find out an attribute.  This patch passes
an attribute syntax info for sorting.

Plus, featuring slapi_berval_cmp for the fallback compare algorithm.
It is closer to the syntax based sorting.

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

Reviewed by rmeggins@redhat.com (Thank you, Rich!)
(cherry picked from commit 136fa64f95263ffcaca5e855b771b5d377e3de52)
Ticket 47779 - Part of DNA shared configuration is deleted after server restart

Bug Description:  After a configuration change, like updating dnaNextVal,
                  the shared config entries are always rebuilt, but they do
                  preserve some of the configuration attributes like dnaRemoteBindMethod.

Fix Description:  Maintain a global linked list of all the shared config entries,
                  so when we go to rebuild the shared config entry we can restore
                  the dnaRemote attributes.

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

Reviewed by: nhosoi(Thanks!)
Ticket 47771 - Move parentsdn initialization to avoid crash

Bug Description:  It's possible to call slapi_sdn_done() before parentsdn is
                  initialized - which will crash the server.

Fix Description:  Initialize parentsdn at the top of the function.

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

Reviewed by: nhosoi(Thanks!)
(cherry picked from commit 991984f1544c096d46a54ed3117542e8c5f3d70c)
Ticket 477779 - Need to lock server list when removing list

Description:  Need to hold the write lock when deleting the server list.
              There is no need to lock the list in the close function,
              as all active threads should be stopped.  In 1.3.3, the
              dynamic plugin feature will also safely handle the plugin
              shutdown.

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

Reviewed by: tbordaz(Thanks!)

(cherry picked from commit 2b98dcaf83fba3ea4fc52c2b8cad6deea02cb0e5)
Ticket 47792 - code cleanup

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

Reviewed by: rmeggins(Thanks!)

(cherry picked from commit d341b7734648e71c1b1ded398971c23b6fbdc1fb)
Ticket #47707 - 389 DS Server crashes and dies while handles paged searches from clients

Bug Description: If a simple paged search request was sent to the server
and the request was abandoned, the paged result slot in the connection
table was not properly released by setting NULL to pr_current_be.  Since
the slot did not look available for the next request even though it was,
the next request failed to get the valid slot number, and the initial slot
number -1 failed to be replaced with the real slot number.  Until the fix
for "Ticket #47623 fix memleak caused by 47347" was made, it overrode the
allocated array's [-1] location, which usually stores the meta data of the
allocated memory.  That crashed the server in the next realloc since the
corrupted memory was passed to the function.

Fix Description: This patch cleans up the abandoned/cleaned up slot for
reuse.  Also, more check not to break the meta data is added.

Special thanks to German Parente (gparente@redhat.com) for providing the
reproducer and analysing the crash.

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

Reviewed by rmeggins@redhat.com (Thanks, Rich!)

(cherry picked from commit 087356f7eaff2dff3c0c4f7dfcaa6aacc9979224)