]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli/auth: let netlogon_creds_copy() make use of ndr_deepcopy_struct()
authorStefan Metzmacher <metze@samba.org>
Wed, 19 Jul 2023 19:04:53 +0000 (21:04 +0200)
committerVolker Lendecke <vl@samba.org>
Thu, 28 Nov 2024 13:53:25 +0000 (13:53 +0000)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Nov 28 13:53:25 UTC 2024 on atb-devel-224

libcli/auth/credentials.c

index 7a1f6038ef278f099fcc655cb0798fdcb1b7958c..53a089bd5b70dd9a7fb2181b83c6422186a75b54 100644 (file)
@@ -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;
 }