if (kret != KRB5_OK)
return kret;
+ /*
+ * DCE includes the principal's realm in the count; the new format
+ * does not.
+ */
+ if (data->version == KRB5_FCC_FVNO_1)
+ length--;
+
tmpprinc = (krb5_principal) malloc(sizeof(krb5_principal_data));
if (tmpprinc == NULL)
return KRB5_CC_NOMEM;
{
krb5_fcc_data *data = (krb5_fcc_data *)id->data;
krb5_error_code ret;
- krb5_int32 i, length, type;
+ krb5_int32 i, length, tmp, type;
type = krb5_princ_type(princ);
- length = krb5_princ_size(princ);
+ tmp = length = krb5_princ_size(princ);
- if (data->version != KRB5_FCC_FVNO_1) {
- ret = krb5_fcc_store_int32(id, &type);
- CHECK(ret);
+ if (data->version == KRB5_FCC_FVNO_1) {
+ /*
+ * DCE-compatible format means that the length count
+ * includes the realm. (It also doesn't include the
+ * principal type information.)
+ */
+ tmp++;
+ } else {
+ ret = krb5_fcc_store_int32(id, &type);
+ CHECK(ret);
}
- ret = krb5_fcc_store_int32(id, &length);
+ ret = krb5_fcc_store_int32(id, &tmp);
CHECK(ret);
ret = krb5_fcc_store_data(id, krb5_princ_realm(princ));
if (kret != KRB5_OK)
return kret;
+ /*
+ * DCE includes the principal's realm in the count; the new format
+ * does not.
+ */
+ if (data->version == KRB5_SCC_FVNO_1)
+ length--;
+
tmpprinc = (krb5_principal) malloc(sizeof(krb5_principal_data));
if (tmpprinc == NULL)
return KRB5_CC_NOMEM;
{
krb5_scc_data *data = (krb5_scc_data *)id->data;
krb5_error_code ret;
- krb5_int32 i, length, type;
+ krb5_int32 i, length, tmp, type;
type = krb5_princ_type(princ);
- length = krb5_princ_size(princ);
+ tmp = length = krb5_princ_size(princ);
- if (data->version != KRB5_SCC_FVNO_1) {
+ if (data->version == KRB5_SCC_FVNO_1) {
+ /*
+ * DCE-compatible format means that the length count
+ * includes the realm. (It also doesn't include the
+ * principal type information.)
+ */
+ tmp++;
+ } else {
ret = krb5_scc_store_int32(id, &type);
CHECK(ret);
}
- ret = krb5_scc_store_int32(id, &length);
+ ret = krb5_scc_store_int32(id, &tmp);
CHECK(ret);
ret = krb5_scc_store_data(id, krb5_princ_realm(princ));