krb5_sname_match() can read past the end of princ's component array in
some circumstances (typically when a keytab contains both "x" and
"x/y" principals). Add a length check. Reported by Spencer Jackson.
(cherry picked from commit
fb9fcfa92fd37221c77e1a4c0b930383e6839e22)
ticket: 8415
version_fixed: 1.13.6
if (matching->type != KRB5_NT_SRV_HST || matching->length != 2)
return krb5_principal_compare(context, matching, princ);
+ if (princ->length != 2)
+ return FALSE;
+
/* Check the realm if present in matching. */
if (matching->realm.length != 0 && !data_eq(matching->realm, princ->realm))
return FALSE;