From: Stefan Metzmacher Date: Wed, 19 Jul 2023 19:04:53 +0000 (+0200) Subject: libcli/auth: let netlogon_creds_copy() make use of ndr_deepcopy_struct() X-Git-Tag: tdb-1.4.13~454 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb92c70f0ee126981a4ffeea28bf7059ab0b08d0;p=thirdparty%2Fsamba.git libcli/auth: let netlogon_creds_copy() make use of ndr_deepcopy_struct() Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Thu Nov 28 13:53:25 UTC 2024 on atb-devel-224 --- diff --git a/libcli/auth/credentials.c b/libcli/auth/credentials.c index 7a1f6038ef2..53a089bd5b7 100644 --- a/libcli/auth/credentials.c +++ b/libcli/auth/credentials.c @@ -22,6 +22,7 @@ #include "includes.h" #include "system/time.h" +#include "librpc/gen_ndr/ndr_schannel.h" #include "libcli/auth/libcli_auth.h" #include "../libcli/security/dom_sid.h" #include "lib/util/util_str_escape.h" @@ -1408,33 +1409,18 @@ struct netlogon_creds_CredentialState *netlogon_creds_copy( const struct netlogon_creds_CredentialState *creds_in) { struct netlogon_creds_CredentialState *creds = talloc_zero(mem_ctx, struct netlogon_creds_CredentialState); + enum ndr_err_code ndr_err; if (!creds) { return NULL; } - *creds = *creds_in; - - creds->computer_name = talloc_strdup(creds, creds_in->computer_name); - if (!creds->computer_name) { - talloc_free(creds); - return NULL; - } - creds->account_name = talloc_strdup(creds, creds_in->account_name); - if (!creds->account_name) { - talloc_free(creds); + ndr_err = ndr_deepcopy_struct(netlogon_creds_CredentialState, + creds_in, creds, creds); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + TALLOC_FREE(creds); return NULL; } - if (creds_in->ex != NULL) { - creds->ex = talloc_zero(creds, - struct netlogon_creds_CredentialState_extra_info); - if (creds->ex == NULL) { - talloc_free(creds); - return NULL; - } - *creds->ex = *creds_in->ex; - } - return creds; }