diff options
author | Günther Deschner <gd@samba.org> | 2008-03-28 13:36:31 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2008-03-28 13:36:31 +0100 |
commit | 76a819c9c0e8f0636e455e203bdbe086f34e1b6c (patch) | |
tree | ab2a8d716ddfda6ebf6c89d0d1f87c53b6ef1282 | |
parent | 67ba3cd67eebaeeb1fe526a426712ae83c97c518 (diff) | |
download | samba-76a819c9c0e8f0636e455e203bdbe086f34e1b6c.tar.gz samba-76a819c9c0e8f0636e455e203bdbe086f34e1b6c.tar.bz2 samba-76a819c9c0e8f0636e455e203bdbe086f34e1b6c.zip |
Use NDR for netr_DsRGetDCNameInfo un-/marshalling in dsgetdcname.
Guenther
(This used to be commit 7fa53911054a39681df3f08d19aad92f60d59e28)
-rw-r--r-- | source3/libsmb/dsgetdcname.c | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c index bc9f4b92c8..d0a08fddb7 100644 --- a/source3/libsmb/dsgetdcname.c +++ b/source3/libsmb/dsgetdcname.c @@ -298,8 +298,7 @@ static NTSTATUS dsgetdcname_cache_store(TALLOC_CTX *mem_ctx, char *key; bool ret = false; DATA_BLOB blob; - unsigned char *buf = NULL; - int len = 0; + enum ndr_err_code ndr_err; if (!gencache_init()) { return NT_STATUS_INTERNAL_DB_ERROR; @@ -312,14 +311,12 @@ static NTSTATUS dsgetdcname_cache_store(TALLOC_CTX *mem_ctx, expire_time = time(NULL) + DSGETDCNAME_CACHE_TTL; - len = pack_dsdcinfo(info, &buf); - if (len == -1) { - return NT_STATUS_UNSUCCESSFUL; + ndr_err = ndr_push_struct_blob(&blob, mem_ctx, info, + (ndr_push_flags_fn_t)ndr_push_netr_DsRGetDCNameInfo); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return ndr_map_error2ntstatus(ndr_err); } - blob = data_blob(buf, len); - SAFE_FREE(buf); - if (gencache_lock_entry(key) != 0) { data_blob_free(&blob); return NT_STATUS_LOCK_NOT_GRANTED; @@ -404,12 +401,13 @@ static NTSTATUS dsgetdcname_cache_fetch(TALLOC_CTX *mem_ctx, struct GUID *domain_guid, uint32_t flags, const char *site_name, - struct netr_DsRGetDCNameInfo **info, + struct netr_DsRGetDCNameInfo **info_p, bool *expired) { char *key; DATA_BLOB blob; - NTSTATUS status; + enum ndr_err_code ndr_err; + struct netr_DsRGetDCNameInfo *info; if (!gencache_init()) { return NT_STATUS_INTERNAL_DB_ERROR; @@ -424,25 +422,37 @@ static NTSTATUS dsgetdcname_cache_fetch(TALLOC_CTX *mem_ctx, return NT_STATUS_OBJECT_NAME_NOT_FOUND; } - status = unpack_dsdcinfo(mem_ctx, blob.data, blob.length, info); - if (!NT_STATUS_IS_OK(status)) { - data_blob_free(&blob); - return status; + info = TALLOC_ZERO_P(mem_ctx, struct netr_DsRGetDCNameInfo); + if (!info) { + return NT_STATUS_NO_MEMORY; } + ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, info, + (ndr_pull_flags_fn_t)ndr_pull_netr_DsRGetDCNameInfo); + data_blob_free(&blob); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + dsgetdcname_cache_delete(mem_ctx, domain_name); + return ndr_map_error2ntstatus(ndr_err); + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_DEBUG(netr_DsRGetDCNameInfo, info); + } /* check flags */ - if (!check_cldap_reply_required_flags((*info)->dc_flags, flags)) { + if (!check_cldap_reply_required_flags(info->dc_flags, flags)) { DEBUG(10,("invalid flags\n")); return NT_STATUS_INVALID_PARAMETER; } if ((flags & DS_IP_REQUIRED) && - ((*info)->dc_address_type != DS_ADDRESS_TYPE_INET)) { + (info->dc_address_type != DS_ADDRESS_TYPE_INET)) { return NT_STATUS_INVALID_PARAMETER_MIX; } + *info_p = info; + return NT_STATUS_OK; } |