From: Joseph Sutton Date: Thu, 21 Sep 2023 00:01:27 +0000 (+1200) Subject: s4:kdc: Check for overflow before calling smb_krb5_princ_component() X-Git-Tag: talloc-2.4.2~1003 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ea6d2ddb66ec28097c1fe47e2d0a9ab8c1f3e7c6;p=thirdparty%2Fsamba.git s4:kdc: Check for overflow before calling smb_krb5_princ_component() 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 Reviewed-by: Andrew Bartlett --- diff --git a/source4/kdc/db-glue.c b/source4/kdc/db-glue.c index 2450b58e66f..32ef4041083 100644 --- a/source4/kdc/db-glue.c +++ b/source4/kdc/db-glue.c @@ -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;