From f4f194aad102fb6c8740867ac198e1cad0796b63 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 8 Jun 2006 01:00:46 +0000 Subject: r16086: Ensure we can never dereference NULL pointers, and that describe what these two DN comparison functions do. Andrew Bartlett (This used to be commit 733b64a733779daade7d1cabbacac2275564b697) --- source4/lib/ldb/common/ldb_dn.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c index 9f3374bceb..b90d3d8c9b 100644 --- a/source4/lib/ldb/common/ldb_dn.c +++ b/source4/lib/ldb/common/ldb_dn.c @@ -478,23 +478,25 @@ failed: return NULL; } -/* compare DNs using casefolding compare functions */ +/* Determine if dn is below base, in the ldap tree. Used for + * evaluating a subtree search. + * 0 if they match, otherwise non-zero + */ int ldb_dn_compare_base(struct ldb_context *ldb, - const struct ldb_dn *base, - const struct ldb_dn *dn) + const struct ldb_dn *base, + const struct ldb_dn *dn) { int ret; int n0, n1; + if (base == NULL || base->comp_num == 0) return 0; + if (dn == NULL || dn->comp_num == 0) return -1; + if (base->comp_num > dn->comp_num) { return (dn->comp_num - base->comp_num); } - if (base == NULL || base->comp_num == 0) return 0; - if (dn == NULL || dn->comp_num == 0) return -1; - if (base->comp_num > dn->comp_num) return -1; - /* if the number of components doesn't match they differ */ n0 = base->comp_num - 1; n1 = dn->comp_num - 1; @@ -522,6 +524,11 @@ int ldb_dn_compare_base(struct ldb_context *ldb, return 0; } +/* compare DNs using casefolding compare functions. + + If they match, then return 0 + */ + int ldb_dn_compare(struct ldb_context *ldb, const struct ldb_dn *edn0, const struct ldb_dn *edn1) -- cgit