Fix deleted node handling in libprofile

In profile_find_node, skip deleted nodes when finding the second
match.  Otherwise, profile_clear_nodes could return an error if a node
has some values to clear but the last one is deleted.

In profile_node_iterator, skip deleted nodes when looking up the
section names.  Otherwise we could iterate over a deleted section
and/or ignore its replacement.

(cherry picked from commit e7f50a1c11845ba73ce4ffa4729d10113563a247)

ticket: 7971
version_fixed: 1.12.2
status: resolved
Fix creation/rename of top-level profile sections

profile_rename_section should demand only one name.

profile_add_relation should demand only one name if it is creating a
new section.  It aso needs to reset state before calling
profile_find_node for the section, in case it didn't look up any
parent sections previously.

(cherry picked from commit 590df2f41f84e0f9492e08f7dbd26fbcd3118ea0)

ticket: 7972
version_fixed: 1.12.2
status: resolved
Use zapfree in krb5_decrypt_tkt_part

(cherry picked from commit 18333f731b8cb3b4610b1d623caef9347c785f7b)

ticket: 7982
version_fixed: 1.12.2
status: resolved
Fix LDAP key data segmentation [CVE-2014-4345]

For principal entries having keys with multiple kvnos (due to use of
-keepold), the LDAP KDB module makes an attempt to store all the keys
having the same kvno into a single krbPrincipalKey attribute value.
There is a fencepost error in the loop, causing currkvno to be set to
the just-processed value instead of the next kvno.  As a result, the
second and all following groups of multiple keys by kvno are each
stored in two krbPrincipalKey attribute values.  Fix the loop to use
the correct kvno value.

CVE-2014-4345:

In MIT krb5, when kadmind is configured to use LDAP for the KDC
database, an authenticated remote attacker can cause it to perform an
out-of-bounds write (buffer overrun) by performing multiple cpw
-keepold operations.  An off-by-one error while copying key
information to the new database entry results in keys sharing a common
kvno being written to different array buckets, in an array whose size
is determined by the number of kvnos present.  After sufficient
iterations, the extra writes extend past the end of the
(NULL-terminated) array.  The NULL terminator is always written after
the end of the loop, so no out-of-bounds data is read, it is only
written.

Historically, it has been possible to convert an out-of-bounds write
into remote code execution in some cases, though the necessary
exploits must be tailored to the individual application and are
usually quite complicated.  Depending on the allocated length of the
array, an out-of-bounds write may also cause a segmentation fault
and/or application crash.

    CVSSv2 Vector: AV:N/AC:M/Au:S/C:C/I:C/A:C/E:POC/RL:OF/RC:C

[ghudson@mit.edu: clarified commit message]
[kaduk@mit.edu: CVE summary, CVSSv2 vector]

(cherry picked from commit 81c332e29f10887c6b9deb065f81ba259f4c7e03)

ticket: 7980
version_fixed: 1.12.2
status: resolved
Add regression test for LDAP key fencepost bug

(cherry picked from commit 0d78da225612e13d0b1cf515987305535d2f9dce)

ticket: 7980
status: resolved