From: Theodore Tso Date: Fri, 10 Sep 1993 22:07:29 +0000 (+0000) Subject: Change the version one credentials cache code so that the length field X-Git-Tag: krb5-1.0-beta3~195 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=59e7414224061331f32de525ceecb040a3b7b4fa;p=krb5.git Change the version one credentials cache code so that the length field is used in the DCE version of Kerberos. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2643 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/ccache/file/fcc_read.c b/src/lib/krb5/ccache/file/fcc_read.c index 13807e2c8..5cea96887 100644 --- a/src/lib/krb5/ccache/file/fcc_read.c +++ b/src/lib/krb5/ccache/file/fcc_read.c @@ -103,6 +103,13 @@ krb5_fcc_read_principal(id, 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_FCC_FVNO_1) + length--; + tmpprinc = (krb5_principal) malloc(sizeof(krb5_principal_data)); if (tmpprinc == NULL) return KRB5_CC_NOMEM; diff --git a/src/lib/krb5/ccache/file/fcc_write.c b/src/lib/krb5/ccache/file/fcc_write.c index dd30f369c..1e138ce95 100644 --- a/src/lib/krb5/ccache/file/fcc_write.c +++ b/src/lib/krb5/ccache/file/fcc_write.c @@ -80,17 +80,24 @@ krb5_fcc_store_principal(id, princ) { 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)); diff --git a/src/lib/krb5/ccache/stdio/scc_read.c b/src/lib/krb5/ccache/stdio/scc_read.c index bc6ddd8db..a8eedc050 100644 --- a/src/lib/krb5/ccache/stdio/scc_read.c +++ b/src/lib/krb5/ccache/stdio/scc_read.c @@ -103,6 +103,13 @@ krb5_scc_read_principal(id, 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; diff --git a/src/lib/krb5/ccache/stdio/scc_write.c b/src/lib/krb5/ccache/stdio/scc_write.c index f54260c3a..ce0693e90 100644 --- a/src/lib/krb5/ccache/stdio/scc_write.c +++ b/src/lib/krb5/ccache/stdio/scc_write.c @@ -83,17 +83,24 @@ krb5_scc_store_principal(id, princ) { 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));