]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli/security: simplify logic in add_sid_to_array_attrs()
authorStefan Metzmacher <metze@samba.org>
Wed, 29 Jan 2025 08:43:44 +0000 (09:43 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 14 Feb 2025 14:21:33 +0000 (14:21 +0000)
(struct auth_SidAttr) {} makes sure we don't leave uninitialized
memory in case struct auth_SidAttr will change (which will happen in
the next commits).

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
libcli/security/util_sid.c

index 6f45c1be3123a5bb66399db2ed2a6ad3824b83c5..f69ad76d62956d26c8ceb496c1bd0cd8bb405990 100644 (file)
@@ -444,6 +444,10 @@ NTSTATUS add_sid_to_array_attrs(TALLOC_CTX *mem_ctx,
 {
        struct auth_SidAttr *tmp = NULL;
 
+       if (sid == NULL) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
        if ((*num) == UINT32_MAX) {
                return NT_STATUS_INTEGER_OVERFLOW;
        }
@@ -455,8 +459,10 @@ NTSTATUS add_sid_to_array_attrs(TALLOC_CTX *mem_ctx,
        }
        *sids = tmp;
 
-       sid_copy(&((*sids)[*num].sid), sid);
-       (*sids)[*num].attrs = attrs;
+       (*sids)[*num] = (struct auth_SidAttr) {
+               .sid = *sid,
+               .attrs = attrs,
+       };
        *num += 1;
 
        return NT_STATUS_OK;