diff options
author | Andrew Bartlett <abartlet@samba.org> | 2006-07-12 01:25:20 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:10:04 -0500 |
commit | e071f4abd29e0c321200ae74ee08d9b2cbf24b94 (patch) | |
tree | 33a1c985c34ecc438da4d67c9ddfaef1a1e6bfec /source4 | |
parent | 795c27946231501a7e1ca32a5e8899b3624bbde5 (diff) | |
download | samba-e071f4abd29e0c321200ae74ee08d9b2cbf24b94.tar.gz samba-e071f4abd29e0c321200ae74ee08d9b2cbf24b94.tar.bz2 samba-e071f4abd29e0c321200ae74ee08d9b2cbf24b94.zip |
r16965: Take a better stab at comparison functions between string and binary
forms of the objectGUID and objectSID attributes.
Andrew Bartlett
(This used to be commit e7894b49b37de296320fea2e6d86052b81845e51)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/ldb/samba/ldif_handlers.c | 68 |
1 files changed, 44 insertions, 24 deletions
diff --git a/source4/lib/ldb/samba/ldif_handlers.c b/source4/lib/ldb/samba/ldif_handlers.c index b7015b833a..8228f6e51a 100644 --- a/source4/lib/ldb/samba/ldif_handlers.c +++ b/source4/lib/ldb/samba/ldif_handlers.c @@ -93,19 +93,28 @@ static BOOL ldb_comparision_objectSid_isString(const struct ldb_val *v) 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)) { - if (ldb_comparision_objectSid_isString(v2)) { - return strcmp((const char *)v1->data, (const char *)v2->data); - } else { - struct ldb_val v; - int ret; - if (ldif_read_objectSid(ldb, mem_ctx, v1, &v) != 0) { - return -1; - } - ret = ldb_comparison_binary(ldb, mem_ctx, &v, v2); - talloc_free(v.data); - return ret; + if (ldb_comparision_objectSid_isString(v1) && ldb_comparision_objectSid_isString(v2)) { + return strcmp((const char *)v1->data, (const char *)v2->data); + } 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; } + ret = ldb_comparison_binary(ldb, mem_ctx, &v, v2); + talloc_free(v.data); + return ret; + } 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, v2, &v) != 0) { + return -1; + } + ret = ldb_comparison_binary(ldb, mem_ctx, v1, &v); + talloc_free(v.data); + return ret; } return ldb_comparison_binary(ldb, mem_ctx, v1, v2); } @@ -173,6 +182,8 @@ static BOOL ldb_comparision_objectGUID_isString(const struct ldb_val *v) /* see if the input if null-terninated */ if (v->data[v->length] != '\0') return False; + if (v->length < 33) return False; + status = GUID_from_string((const char *)v->data, &guid); if (!NT_STATUS_IS_OK(status)) { return False; @@ -187,19 +198,28 @@ static BOOL ldb_comparision_objectGUID_isString(const struct ldb_val *v) 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)) { - if (ldb_comparision_objectGUID_isString(v2)) { - return strcmp((const char *)v1->data, (const char *)v2->data); - } else { - struct ldb_val v; - int ret; - if (ldif_read_objectGUID(ldb, mem_ctx, v1, &v) != 0) { - return -1; - } - ret = ldb_comparison_binary(ldb, mem_ctx, &v, v2); - talloc_free(v.data); - return ret; + if (ldb_comparision_objectGUID_isString(v1) && ldb_comparision_objectGUID_isString(v2)) { + return strcmp((const char *)v1->data, (const char *)v2->data); + } 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; + } + ret = ldb_comparison_binary(ldb, mem_ctx, &v, v2); + talloc_free(v.data); + return ret; + } 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, v2, &v) != 0) { + return -1; } + ret = ldb_comparison_binary(ldb, mem_ctx, v1, &v); + talloc_free(v.data); + return ret; } return ldb_comparison_binary(ldb, mem_ctx, v1, v2); } |