svn commit: samba r16965 - in
branches/SAMBA_4_0/source/lib/ldb/samba: .
abartlet at samba.org
abartlet at samba.org
Wed Jul 12 01:25:22 GMT 2006
Author: abartlet
Date: 2006-07-12 01:25:20 +0000 (Wed, 12 Jul 2006)
New Revision: 16965
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16965
Log:
Take a better stab at comparison functions between string and binary
forms of the objectGUID and objectSID attributes.
Andrew Bartlett
Modified:
branches/SAMBA_4_0/source/lib/ldb/samba/ldif_handlers.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/samba/ldif_handlers.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/samba/ldif_handlers.c 2006-07-12 00:56:27 UTC (rev 16964)
+++ branches/SAMBA_4_0/source/lib/ldb/samba/ldif_handlers.c 2006-07-12 01:25:20 UTC (rev 16965)
@@ -93,19 +93,28 @@
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 @@
/* 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 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);
}
More information about the samba-cvs
mailing list