]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
dsdb: Slightly simplify dsdb_trust_get_incoming_passwords()
authorVolker Lendecke <vl@samba.org>
Fri, 6 Oct 2023 06:00:06 +0000 (08:00 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 10 Oct 2023 23:23:40 +0000 (23:23 +0000)
Use talloc_memdup() instead of a manual copy.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/dsdb/common/util_trusts.c

index 175af65544309a11fec92cda4d0f0cf06f60ee2d..5003e7499b01084b8ed0773bc16cb30b694d14c1 100644 (file)
@@ -2746,15 +2746,15 @@ NTSTATUS dsdb_trust_get_incoming_passwords(struct ldb_message *msg,
        }
 
        if (_current != NULL) {
-               *_current = talloc(mem_ctx, struct samr_Password);
+               *_current = talloc_memdup(mem_ctx, current, sizeof(*current));
                if (*_current == NULL) {
                        TALLOC_FREE(frame);
                        return NT_STATUS_NO_MEMORY;
                }
-               **_current = *current;
        }
        if (_previous != NULL) {
-               *_previous = talloc(mem_ctx, struct samr_Password);
+               *_previous =
+                       talloc_memdup(mem_ctx, previous, sizeof(*previous));
                if (*_previous == NULL) {
                        if (_current != NULL) {
                                TALLOC_FREE(*_current);
@@ -2762,7 +2762,6 @@ NTSTATUS dsdb_trust_get_incoming_passwords(struct ldb_message *msg,
                        TALLOC_FREE(frame);
                        return NT_STATUS_NO_MEMORY;
                }
-               **_previous = *previous;
        }
        ZERO_STRUCTP(current);
        ZERO_STRUCTP(previous);