]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
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)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 19 Jun 2020 08:35:33 +0000 (08:35 +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

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;
 }