Author: abartlet Date: 2006-09-11 07:50:49 +0000 (Mon, 11 Sep 2006) New Revision: 18367
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=18367 Log: When converting to entryUUID, ensure we don't double-convert a string-format GUID. Andrew Bartlett Modified: branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/entryUUID.c Changeset: Modified: branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/entryUUID.c =================================================================== --- branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/entryUUID.c 2006-09-11 07:15:49 UTC (rev 18366) +++ branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/entryUUID.c 2006-09-11 07:50:49 UTC (rev 18367) @@ -58,24 +58,27 @@ 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 @@ .u = { .convert = { .remote_name = "entryUUID", - .convert_local = decode_guid, + .convert_local = guid_always_string, .convert_remote = encode_guid, }, },