From 125c06db18577f60bd81dacb0ea250bf9ccafdd0 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Thu, 6 Jul 2017 10:01:24 +1200 Subject: [PATCH 2/3] ldb: avoid searching empty lists in ldb_msg_find_common_values BUG: https://bugzilla.samba.org/show_bug.cgi?id=12900 Signed-off-by: Douglas Bagnall Reviewed-by: Andreas Schneider (cherry picked from commit 282410fa2416404962521ad6b2598a9c83b63594) --- lib/ldb/common/ldb_msg.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ldb/common/ldb_msg.c b/lib/ldb/common/ldb_msg.c index 8e4047b..c2782db 100644 --- a/lib/ldb/common/ldb_msg.c +++ b/lib/ldb/common/ldb_msg.c @@ -207,6 +207,9 @@ int ldb_msg_find_common_values(struct ldb_context *ldb, if (strcmp(el->name, el2->name) != 0) { return LDB_ERR_INAPPROPRIATE_MATCHING; } + if (el->num_values == 0 || el2->num_values == 0) { + return LDB_SUCCESS; + } /* With few values, it is better to do the brute-force search than the clever search involving tallocs, memcpys, sorts, etc. -- 2.7.4