]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli/security: add_claim_to_token() re-sorts/checks claims
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 22 Nov 2023 03:38:13 +0000 (16:38 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 27 Nov 2023 22:37:32 +0000 (22:37 +0000)
This function is used in tests and fuzzing.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
libcli/security/claims-conversions.c

index 214249270d0a521a6ae7db41354671e2fc7c1b48..770795e29e7ad363befcf0afd0534d12b2003d38 100644 (file)
@@ -693,6 +693,7 @@ bool add_claim_to_token(TALLOC_CTX *mem_ctx,
                        const char *claim_type)
 {
        struct CLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1 *tmp = NULL;
+       NTSTATUS status;
        uint32_t *n = NULL;
        bool ok;
        struct CLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1 **list = NULL;
@@ -722,8 +723,19 @@ bool add_claim_to_token(TALLOC_CTX *mem_ctx,
 
        ok = claim_v1_copy(mem_ctx, &tmp[*n], claim);
        if (! ok ) {
+               TALLOC_FREE(tmp);
+               return false;
+       }
+
+       status = claim_v1_check_and_sort(tmp, &tmp[*n],
+                                        claim->flags & CLAIM_SECURITY_ATTRIBUTE_VALUE_CASE_SENSITIVE);
+       if (!NT_STATUS_IS_OK(status)) {
+               DBG_WARNING("resource attribute claim sort failed with %s\n",
+                           nt_errstr(status));
+               TALLOC_FREE(tmp);
                return false;
        }
+
        (*n)++;
        *list = tmp;
        return true;