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)
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

index d7222997732983833d5ff7276396df5e14ab47b4..0531f8a62ae3d2148b3b4682d63bb4419cace112 100644 (file)
@@ -176,8 +176,6 @@ static int lldb_add_msg_attr(struct ldb_context *ldb,
                el->num_values++;
        }
 
-       msg->num_elements++;
-
        return 0;
 }