krb5: skip vanished keyring ccache keys

This commit is contained in:
Roland C. Dowdeswell
2026-06-10 16:42:23 +01:00
committed by Nico Williams
parent 8a0fc8d032
commit 97b07c5632
+24 -18
View File
@@ -1193,28 +1193,34 @@ krcc_get_next(krb5_context context,
if (krcursor == NULL)
return KRB5_CC_END;
if (krcursor->currkey >= krcursor->numkeys)
return KRB5_CC_END;
/*
* If we're pointing at the entry with the principal, or at the key
* with the time offsets, skip it.
*/
while (krcursor->keys[krcursor->currkey] == krcursor->princ_id ||
krcursor->keys[krcursor->currkey] == krcursor->offsets_id) {
krcursor->currkey++;
for (;;) {
if (krcursor->currkey >= krcursor->numkeys)
return KRB5_CC_END;
}
ret = keyctl_read_krb5_data(krcursor->keys[krcursor->currkey], &payload);
if (ret) {
_krb5_debug(context, 10, "Error reading key %d: %s\n",
krcursor->keys[krcursor->currkey],
strerror(errno));
return ret;
/*
* If we're pointing at the entry with the principal, or at the key
* with the time offsets, skip it.
*/
while (krcursor->keys[krcursor->currkey] == krcursor->princ_id ||
krcursor->keys[krcursor->currkey] == krcursor->offsets_id) {
krcursor->currkey++;
if (krcursor->currkey >= krcursor->numkeys)
return KRB5_CC_END;
}
ret = keyctl_read_krb5_data(krcursor->keys[krcursor->currkey],
&payload);
krcursor->currkey++;
if (ret == KRB5_FCC_NOFILE)
continue;
if (ret) {
_krb5_debug(context, 10, "Error reading key %d: %s\n",
krcursor->keys[krcursor->currkey - 1],
strerror(errno));
return ret;
}
break;
}
krcursor->currkey++;
sp = krb5_storage_from_data(&payload);
if (sp == NULL) {