]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib/krb5_wrap: prefer new enctyptes in ms_suptypes_to_ietf_enctypes()
authorStefan Metzmacher <metze@samba.org>
Fri, 29 Nov 2019 12:47:16 +0000 (13:47 +0100)
committerStefan Metzmacher <metze@samba.org>
Mon, 10 Feb 2020 16:32:36 +0000 (16:32 +0000)
This is currently not critical as we only use keytabs
only as acceptor, but in future we'll also use them
for kinit() and there we should prefer the newest type.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
lib/krb5_wrap/enctype_convert.c

index a658911190a10325c8e38fb477d4d2437616ca5f..4a644358c174cd5ed7f40412a4adf667ec836216 100644 (file)
@@ -83,13 +83,17 @@ krb5_error_code ms_suptypes_to_ietf_enctypes(TALLOC_CTX *mem_ctx,
                                             uint32_t enctype_bitmap,
                                             krb5_enctype **enctypes)
 {
-       unsigned int i, j = 0;
+       size_t max_bits = 8 * sizeof(enctype_bitmap);
+       size_t j = 0;
+       ssize_t i;
+
        *enctypes = talloc_zero_array(mem_ctx, krb5_enctype,
-                                       (8 * sizeof(enctype_bitmap)) + 1);
+                                     max_bits + 1);
        if (!*enctypes) {
                return ENOMEM;
        }
-       for (i = 0; i < (8 * sizeof(enctype_bitmap)); i++) {
+
+       for (i = max_bits - 1; i >= 0; i--) {
                uint32_t bit_value = (1U << i) & enctype_bitmap;
                if (bit_value & enctype_bitmap) {
                        (*enctypes)[j] = ms_suptype_to_ietf_enctype(bit_value);