1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

ldb:ldb_pack: filter avoids looping over msg when attrs contain "*"

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Douglas Bagnall 2024-07-26 15:47:03 +12:00 committed by Douglas Bagnall
parent df3f7be326
commit 77ad9096d0

View File

@ -1294,13 +1294,18 @@ int ldb_filter_attrs_in_place(struct ldb_message *msg,
keep_all = true;
}
if (keep_all) {
return LDB_SUCCESS;
}
/*
* Find the intersection between the msg elements and attrs.
*
* TODO, maybe: use a faster algorithm when (n * m) is too large.
*/
for (i = 0; i < msg->num_elements; i++) {
bool found = false;
unsigned int j;
if (keep_all) {
found = true;
} else {
for (j = 0; attrs[j]; j++) {
int cmp = ldb_attr_cmp(msg->elements[i].name, attrs[j]);
if (cmp == 0) {
@ -1308,7 +1313,6 @@ int ldb_filter_attrs_in_place(struct ldb_message *msg,
break;
}
}
}
if (!found) {
++num_del;