The LDAP KDB module synthesizes KRB5_TL_CONSTRAINED_DELEGATION_ACL
tl-data when fetching a principal entry, and checks against those
values in krb5_ldap_check_allowed_to_delegate(). To avoid a locally
incorrect use of a counted data type, adjust the synthesized
attributes to include the trailing zero byte in tl_data_length, and
verify the zero terminator before calling krb5_parse_name() on the
value.
for (tlp = server->tl_data; tlp != NULL; tlp = tlp->tl_data_next) {
krb5_principal acl;
- if (tlp->tl_data_type != KRB5_TL_CONSTRAINED_DELEGATION_ACL)
+ if (tlp->tl_data_type != KRB5_TL_CONSTRAINED_DELEGATION_ACL ||
+ tlp->tl_data_length < 1 ||
+ tlp->tl_data_contents[tlp->tl_data_length - 1] != '\0')
continue;
if (krb5_parse_name(context, (char *)tlp->tl_data_contents, &acl) != 0)
if (tl == NULL)
goto cleanup;
tl->tl_data_type = KRB5_TL_CONSTRAINED_DELEGATION_ACL;
- tl->tl_data_length = strlen(a2d2[i]);
+ tl->tl_data_length = strlen(a2d2[i]) + 1;
tl->tl_data_contents = (unsigned char *)strdup(a2d2[i]);
if (tl->tl_data_contents == NULL) {
ret = ENOMEM;