s4:kdc: Check for overflow before calling smb_krb5_princ_component()
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Thu, 21 Sep 2023 00:01:27 +0000 (12:01 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 26 Oct 2023 01:24:32 +0000 (01:24 +0000)
smb_krb5_princ_component() takes its component index parameter as ‘int’,
not ‘unsigned int’.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15482

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/kdc/db-glue.c

index 2450b58e66f4e9ee91a214bc5348f80e255a0dfe..32ef4041083eef146950f467fc42acc912655b40 100644 (file)
@@ -912,6 +912,11 @@ static krb5_error_code principal_comp_strcmp_int(krb5_context context,
        size_t len;
        krb5_data d;
        krb5_error_code ret = 0;
+
+       if (component > INT_MAX) {
+               return EINVAL;
+       }
+
        if (component >= krb5_princ_size(context, principal)) {
                /* A non‐existent component compares less than any string. */
                *cmp = -1;