CVE-2023-0614 ldb: Make ldb_filter_attrs_in_place() work in place
commit4addeaaf5da96ac8f620a0c27c2a576b17747dd2
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Fri, 3 Mar 2023 04:30:19 +0000 (3 17:30 +1300)
committerJule Anger <janger@samba.org>
Mon, 20 Mar 2023 09:03:38 +0000 (20 10:03 +0100)
tree19b7ac20615bacd6c0d9beb4f578caea47c75927
parent7c2d0e0a06e6c3523f1ad3fba514505ca094f2fd
CVE-2023-0614 ldb: Make ldb_filter_attrs_in_place() work in place

ldb_filter_attrs() previously did too much. Now its replacement,
ldb_filter_attrs_in_place(), only does the actual filtering, while
taking ownership of each element's values is handled in a separate
function, ldb_msg_elements_take_ownership().

Also, ldb_filter_attrs_in_place() no longer adds the distinguishedName
to the message if it is missing. That is handled in another function,
ldb_msg_add_distinguished_name().

As we're now modifying the original message rather than copying it into
a new one, we no longer need the filtered_msg parameter.

We adapt a test, based on ldb_filter_attrs_test, to exercise the new
function.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15270

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/common/ldb_pack.c
lib/ldb/include/ldb_module.h
lib/ldb/tests/ldb_filter_attrs_in_place_test.c