From a41b696346bd3c525d09fa97bdf487aa809f3c73 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 11 Sep 2006 07:50:49 +0000 Subject: r18367: When converting to entryUUID, ensure we don't double-convert a string-format GUID. Andrew Bartlett (This used to be commit 11cc6408c93f46f4d9ae7ae0ee18dac836fe270d) --- source4/dsdb/samdb/ldb_modules/entryUUID.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'source4/dsdb/samdb/ldb_modules/entryUUID.c') diff --git a/source4/dsdb/samdb/ldb_modules/entryUUID.c b/source4/dsdb/samdb/ldb_modules/entryUUID.c index d6f4b10d76..29e80ff003 100644 --- a/source4/dsdb/samdb/ldb_modules/entryUUID.c +++ b/source4/dsdb/samdb/ldb_modules/entryUUID.c @@ -58,24 +58,27 @@ static struct ldb_val encode_guid(struct ldb_module *module, TALLOC_CTX *ctx, co return out; } -static struct ldb_val decode_guid(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val) +static struct ldb_val guid_always_string(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val) { struct GUID *guid; NTSTATUS status; struct ldb_val out = data_blob(NULL, 0); - - guid = talloc(ctx, struct GUID); - if (guid == NULL) { - return out; - } - status = ndr_pull_struct_blob(val, guid, guid, - (ndr_pull_flags_fn_t)ndr_pull_GUID); - if (!NT_STATUS_IS_OK(status)) { + if (val->length >= 32 && val->data[val->length] == '\0') { + ldb_handler_copy(module->ldb, ctx, val, &out); + } else { + guid = talloc(ctx, struct GUID); + if (guid == NULL) { + return out; + } + status = ndr_pull_struct_blob(val, guid, guid, + (ndr_pull_flags_fn_t)ndr_pull_GUID); + if (!NT_STATUS_IS_OK(status)) { + talloc_free(guid); + return out; + } + out = data_blob_string_const(GUID_string(ctx, guid)); talloc_free(guid); - return out; } - out = data_blob_string_const(GUID_string(ctx, guid)); - talloc_free(guid); return out; } @@ -179,7 +182,7 @@ const struct ldb_map_attribute entryUUID_attributes[] = .u = { .convert = { .remote_name = "entryUUID", - .convert_local = decode_guid, + .convert_local = guid_always_string, .convert_remote = encode_guid, }, }, -- cgit