summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2008-12-04 10:38:07 +1100
committerAndrew Bartlett <abartlet@samba.org>2008-12-17 12:29:23 +1100
commit56d39e1711854f4e82f8370955a34539be22c483 (patch)
tree7f70b51e91453f2c0aae46671e9c79ac4eea6752 /source4/dsdb
parentd2ec925c63fdcfd102f7adcc345ce9f1fe886fd3 (diff)
downloadsamba-56d39e1711854f4e82f8370955a34539be22c483.tar.gz
samba-56d39e1711854f4e82f8370955a34539be22c483.tar.bz2
samba-56d39e1711854f4e82f8370955a34539be22c483.zip
Make greater use of 'GUID_from_data_blob'
This avoids accidentily running off the end of a string, and uses a single 'guess which type of GUID I have' algorithm. Andrew Bartlett Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/samdb/ldb_modules/simple_ldap_map.c51
1 files changed, 11 insertions, 40 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c b/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c
index c353914e2c..0e42f7869a 100644
--- a/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c
+++ b/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c
@@ -44,7 +44,7 @@ struct entryuuid_private {
static struct ldb_val encode_guid(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
{
struct GUID guid;
- NTSTATUS status = GUID_from_string((char *)val->data, &guid);
+ NTSTATUS status = GUID_from_data_blob(val, &guid);
enum ndr_err_code ndr_err;
struct ldb_val out = data_blob(NULL, 0);
@@ -62,27 +62,13 @@ static struct ldb_val encode_guid(struct ldb_module *module, TALLOC_CTX *ctx, co
static struct ldb_val guid_always_string(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
{
- struct GUID *guid;
struct ldb_val out = data_blob(NULL, 0);
- if (val->length >= 32 && val->data[val->length] == '\0') {
- ldb_handler_copy(module->ldb, ctx, val, &out);
- } else {
- enum ndr_err_code ndr_err;
-
- guid = talloc(ctx, struct GUID);
- if (guid == NULL) {
- return out;
- }
- ndr_err = ndr_pull_struct_blob(val, guid, NULL, guid,
- (ndr_pull_flags_fn_t)ndr_pull_GUID);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- talloc_free(guid);
- return out;
- }
- out = data_blob_string_const(GUID_string(ctx, guid));
- talloc_free(guid);
+ struct GUID guid;
+ NTSTATUS status = GUID_from_data_blob(val, &guid);
+ if (!NT_STATUS_IS_OK(status)) {
+ return out;
}
- return out;
+ return data_blob_string_const(GUID_string(ctx, &guid));
}
static struct ldb_val encode_ns_guid(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
@@ -107,27 +93,12 @@ static struct ldb_val encode_ns_guid(struct ldb_module *module, TALLOC_CTX *ctx,
static struct ldb_val guid_ns_string(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
{
struct ldb_val out = data_blob(NULL, 0);
- if (val->length >= 32 && val->data[val->length] == '\0') {
- struct GUID guid;
- GUID_from_string((char *)val->data, &guid);
- out = data_blob_string_const(NS_GUID_string(ctx, &guid));
- } else {
- enum ndr_err_code ndr_err;
- struct GUID *guid_p;
- guid_p = talloc(ctx, struct GUID);
- if (guid_p == NULL) {
- return out;
- }
- ndr_err = ndr_pull_struct_blob(val, guid_p, NULL, guid_p,
- (ndr_pull_flags_fn_t)ndr_pull_GUID);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- talloc_free(guid_p);
- return out;
- }
- out = data_blob_string_const(NS_GUID_string(ctx, guid_p));
- talloc_free(guid_p);
+ struct GUID guid;
+ NTSTATUS status = GUID_from_data_blob(val, &guid);
+ if (!NT_STATUS_IS_OK(status)) {
+ return out;
}
- return out;
+ return data_blob_string_const(NS_GUID_string(ctx, &guid));
}
/* The backend holds binary sids, so just copy them back */