Change the version one credentials cache code so that the length field
authorTheodore Tso <tytso@mit.edu>
Fri, 10 Sep 1993 22:07:29 +0000 (22:07 +0000)
committerTheodore Tso <tytso@mit.edu>
Fri, 10 Sep 1993 22:07:29 +0000 (22:07 +0000)
is used in the DCE version of Kerberos.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2643 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/ccache/file/fcc_read.c
src/lib/krb5/ccache/file/fcc_write.c
src/lib/krb5/ccache/stdio/scc_read.c
src/lib/krb5/ccache/stdio/scc_write.c

index 13807e2c8b8c52f85e3a64e4dbc6bff526904d2c..5cea96887010d99710778c2ee47522b408a35b62 100644 (file)
@@ -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;
index dd30f369cdf607ec440d3df5eee7ea888ec4c6e6..1e138ce9526a6b014fb8f21080a4de8e436fa07a 100644 (file)
@@ -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));
index bc6ddd8db5ee5b602957ee345d6f22fd93a10cfa..a8eedc0500c5bd5bd56436bf842a7d9f59e80ff6 100644 (file)
@@ -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;
index f54260c3ae37e6725d1263841dbfefe27ae2a1dd..ce0693e9070135b139e6818cdf47d8d2784c6f8a 100644 (file)
@@ -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));