mirror of
https://github.com/samba-team/samba.git
synced 2025-01-05 09:18:06 +03:00
libcli: Use ndr_deepcopy_struct() in security_token_duplicate()
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
This commit is contained in:
parent
e37e4d16e9
commit
8ed1b9e874
@ -51,52 +51,27 @@ struct security_token *security_token_initialise(TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
struct security_token *security_token_duplicate(TALLOC_CTX *mem_ctx, const struct security_token *src)
|
struct security_token *security_token_duplicate(TALLOC_CTX *mem_ctx, const struct security_token *src)
|
||||||
{
|
{
|
||||||
TALLOC_CTX *frame = NULL;
|
|
||||||
struct security_token *dst = NULL;
|
struct security_token *dst = NULL;
|
||||||
DATA_BLOB blob;
|
|
||||||
enum ndr_err_code ndr_err;
|
enum ndr_err_code ndr_err;
|
||||||
|
|
||||||
if (src == NULL) {
|
if (src == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
frame = talloc_stackframe();
|
|
||||||
|
|
||||||
ndr_err = ndr_push_struct_blob(
|
|
||||||
&blob,
|
|
||||||
frame,
|
|
||||||
src,
|
|
||||||
(ndr_push_flags_fn_t)ndr_push_security_token);
|
|
||||||
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
|
|
||||||
DBG_ERR("Failed to duplicate security_token ndr_push_security_token failed: %s\n",
|
|
||||||
ndr_errstr(ndr_err));
|
|
||||||
TALLOC_FREE(frame);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
dst = talloc_zero(mem_ctx, struct security_token);
|
dst = talloc_zero(mem_ctx, struct security_token);
|
||||||
if (dst == NULL) {
|
if (dst == NULL) {
|
||||||
DBG_ERR("talloc failed\n");
|
DBG_ERR("talloc failed\n");
|
||||||
TALLOC_FREE(frame);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ndr_err = ndr_pull_struct_blob(
|
ndr_err = ndr_deepcopy_struct(security_token, src, dst, dst);
|
||||||
&blob,
|
|
||||||
dst,
|
|
||||||
dst,
|
|
||||||
(ndr_pull_flags_fn_t)ndr_pull_security_token);
|
|
||||||
|
|
||||||
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
|
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
|
||||||
DBG_ERR("Failed to duplicate security_token ndr_pull_security_token "
|
DBG_ERR("Failed to duplicate security_token: %s\n",
|
||||||
"failed: %s\n",
|
|
||||||
ndr_errstr(ndr_err));
|
ndr_errstr(ndr_err));
|
||||||
TALLOC_FREE(dst);
|
TALLOC_FREE(dst);
|
||||||
TALLOC_FREE(frame);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TALLOC_FREE(frame);
|
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user