ldb_ldap: fix off-by-one increment in lldb_add_msg_attr
authorAlexander Bokovoy <ab@samba.org>
Thu, 18 Jun 2020 07:45:41 +0000 (10:45 +0300)
committerKarolin Seeger <kseeger@samba.org>
Wed, 24 Jun 2020 12:39:28 +0000 (12:39 +0000)
commit9e819be438ae8dd501474e62faf8cf71bd187aa8
treeff323b801ddecc77e941ed624b4e2ad32ce3050d
parent5761f5a199c388282e15f8504a17dd7bfe46f5eb
ldb_ldap: fix off-by-one increment in lldb_add_msg_attr

Fix regression introduced by commit ce2bf5c72b6423fff680b3d6a9042103a6cdda55

lldb_add_msg_attr() calls ldb_msg_add_empty() which, in turn, calls
calls _ldb_msg_add_el() which already increments msg->num_elements by one.

As a result, msg->num_elements is bigger than the actual number of
elements and any iteration over elements would step over elements array
boundary.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14413
Signed-off-by: Alexander Bokovoy <ab@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Jun 19 08:35:33 UTC 2020 on sn-devel-184

(cherry picked from commit 990a0fc4a0481aed817fad7575d8df453fbe7af9)

Autobuild-User(v4-11-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-11-test): Wed Jun 24 12:39:28 UTC 2020 on sn-devel-184
lib/ldb/ldb_ldap/ldb_ldap.c