diff options
author | Andrew Bartlett <abartlet@samba.org> | 2006-06-08 01:00:46 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:08:58 -0500 |
commit | f4f194aad102fb6c8740867ac198e1cad0796b63 (patch) | |
tree | 5cfcb9c2db9804a6492a9a681dadf6489d436ed0 /source4/lib/ldb/common | |
parent | 6664ac88860d3e6d21ce6fdf06d2ff927496a31a (diff) | |
download | samba-f4f194aad102fb6c8740867ac198e1cad0796b63.tar.gz samba-f4f194aad102fb6c8740867ac198e1cad0796b63.tar.bz2 samba-f4f194aad102fb6c8740867ac198e1cad0796b63.zip |
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)
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r-- | source4/lib/ldb/common/ldb_dn.c | 21 |
1 files 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) |