summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2008-08-21 15:10:40 +1000
committerAndrew Bartlett <abartlet@samba.org>2008-08-21 15:10:40 +1000
commitc36c42af296e5bbee1ceaaf66885d7280151a39f (patch)
treedf1ed65664d410a36e8adc1737f1a519447872da /source4/lib
parent8237c0ba83e2b47bb7879ba68d3a50da887397b6 (diff)
downloadsamba-c36c42af296e5bbee1ceaaf66885d7280151a39f.tar.gz
samba-c36c42af296e5bbee1ceaaf66885d7280151a39f.tar.bz2
samba-c36c42af296e5bbee1ceaaf66885d7280151a39f.zip
Handle error cases in attribute handlers better.
We don't need to just bail, for all these error cases there is still real result that can be made - just fall back to binary copy/compare. Andrew Bartlett (This used to be commit 6aa5dde2aa9a5f070871ecc117e44bfcad363459)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/ldb-samba/ldif_handlers.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/source4/lib/ldb-samba/ldif_handlers.c b/source4/lib/ldb-samba/ldif_handlers.c
index 7301193dc2..750e35bca0 100644
--- a/source4/lib/ldb-samba/ldif_handlers.c
+++ b/source4/lib/ldb-samba/ldif_handlers.c
@@ -97,13 +97,14 @@ static int ldb_comparison_objectSid(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *v1, const struct ldb_val *v2)
{
if (ldb_comparision_objectSid_isString(v1) && ldb_comparision_objectSid_isString(v2)) {
- return strcmp((const char *)v1->data, (const char *)v2->data);
+ return ldb_comparison_binary(ldb, mem_ctx, v1, v2);
} else if (ldb_comparision_objectSid_isString(v1)
&& !ldb_comparision_objectSid_isString(v2)) {
struct ldb_val v;
int ret;
if (ldif_read_objectSid(ldb, mem_ctx, v1, &v) != 0) {
- return -1;
+ /* Perhaps not a string after all */
+ return ldb_comparison_binary(ldb, mem_ctx, v1, v2);
}
ret = ldb_comparison_binary(ldb, mem_ctx, &v, v2);
talloc_free(v.data);
@@ -113,7 +114,8 @@ static int ldb_comparison_objectSid(struct ldb_context *ldb, void *mem_ctx,
struct ldb_val v;
int ret;
if (ldif_read_objectSid(ldb, mem_ctx, v2, &v) != 0) {
- return -1;
+ /* Perhaps not a string after all */
+ return ldb_comparison_binary(ldb, mem_ctx, v1, v2);
}
ret = ldb_comparison_binary(ldb, mem_ctx, v1, &v);
talloc_free(v.data);
@@ -129,7 +131,10 @@ static int ldb_canonicalise_objectSid(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *in, struct ldb_val *out)
{
if (ldb_comparision_objectSid_isString(in)) {
- return ldif_read_objectSid(ldb, mem_ctx, in, out);
+ if (ldif_read_objectSid(ldb, mem_ctx, in, out) != 0) {
+ /* Perhaps not a string after all */
+ return ldb_handler_copy(ldb, mem_ctx, in, out);
+ }
}
return ldb_handler_copy(ldb, mem_ctx, in, out);
}
@@ -203,13 +208,14 @@ static int ldb_comparison_objectGUID(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *v1, const struct ldb_val *v2)
{
if (ldb_comparision_objectGUID_isString(v1) && ldb_comparision_objectGUID_isString(v2)) {
- return strcmp((const char *)v1->data, (const char *)v2->data);
+ return ldb_comparison_binary(ldb, mem_ctx, v1, v2);
} else if (ldb_comparision_objectGUID_isString(v1)
&& !ldb_comparision_objectGUID_isString(v2)) {
struct ldb_val v;
int ret;
if (ldif_read_objectGUID(ldb, mem_ctx, v1, &v) != 0) {
- return -1;
+ /* Perhaps it wasn't a valid string after all */
+ return ldb_comparison_binary(ldb, mem_ctx, v1, v2);
}
ret = ldb_comparison_binary(ldb, mem_ctx, &v, v2);
talloc_free(v.data);
@@ -219,7 +225,8 @@ static int ldb_comparison_objectGUID(struct ldb_context *ldb, void *mem_ctx,
struct ldb_val v;
int ret;
if (ldif_read_objectGUID(ldb, mem_ctx, v2, &v) != 0) {
- return -1;
+ /* Perhaps it wasn't a valid string after all */
+ return ldb_comparison_binary(ldb, mem_ctx, v1, v2);
}
ret = ldb_comparison_binary(ldb, mem_ctx, v1, &v);
talloc_free(v.data);
@@ -235,7 +242,10 @@ static int ldb_canonicalise_objectGUID(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *in, struct ldb_val *out)
{
if (ldb_comparision_objectGUID_isString(in)) {
- return ldif_read_objectGUID(ldb, mem_ctx, in, out);
+ if (ldif_read_objectGUID(ldb, mem_ctx, in, out) != 0) {
+ /* Perhaps it wasn't a valid string after all */
+ return ldb_handler_copy(ldb, mem_ctx, in, out);
+ }
}
return ldb_handler_copy(ldb, mem_ctx, in, out);
}